vue.js - Nuxt.js: How to include local images in Markdown blog content?
问题描述
I created a blog in Nuxt.js which uses Markdown for my articles. When writing my first article, I realized I can't include images in my markdown article from my assets
folder. It only works if it's a link like the example below:
Markdown Image:
How can insert an image in Nuxt.js Markdown from this location? assets/images/blog/trees.png
解决方案
In your vue files, you can access images in assets
folder with:
<template>
<img src="~/assets/your_image.png" />
</template>
In markdown file, you can do the same with Markdown syntax:
![image alt text](~/assets/your_image.png)
But as your files in content
folder is independent of webpack, you have to run nuxt generate
each time you add a file in assets
folder.
More info here: https://nuxtjs.org/docs/2.x/directory-structure/assets/ https://github.com/nuxt/content/issues/106
推荐阅读
- javascript - 使用标签选项时,浏览器通知 onclick 事件不会在 chrome 中触发
- android - 嵌套 Volley 调用需要时间在 RecyclerView 中设置数据
- javascript - ES6:以符号为键解构对象
- angular - 为什么路由器事件不显示组件中的路由并显示错误
- json - How to save a list of json data that i get from an API to a class property using fetch
- reactjs - React IIS Hosting(DOM 没有被刷新)
- azure - 用于在 WebApp 中列入白名单的 Azure 前门探测 ip
- php - Laravel:模型(GlobalScope)上的 boot() 方法中的 request->user()
- android - 在 PageKeyedDataSource 中设置 DataSource 大小以获得占位符效果
- amazon-dynamodb - DynamoDB,如何从 begin_with() 中获取 negetion,例如 !begin_with()