Reputation: 107
Hello I just want to put a link to PDF file but it's impossible. There is a library in npm or by another way to do that in VUEJS
I checked this link but it doesn't work
// template
<img src="~assets/images/wtd.jpg">
// image folder
// error
SOLUTION
For images just use
<img src="@/assets/images/image.jpg">
For pdf just put your file in static folder and use this link. In my case I use
<a href="../../static/mypdf.pdf">
Upvotes: 1
Views: 8919
Reputation: 191
If you used vue-cli to create the project. The default image type of 'png|jpe?g|gif|webp' is default supported In template you can use
<img src="~assets/images/demo.png"/>
In script you can use
const demo = require("@/assets/images/demo.png") // @ is a alias in webpack config
or:
import demo from "@/assets/images/demo.png")
For the .pdf file, there is no default loader for this type file. You need config a loader like url-loader for this: https://cli.vuejs.org/config/#configurewebpack
Upvotes: 0
Reputation: 3520
If you're using the project created by vue-cli, then below syntax will work e.g
<img src="@/assets/images/{{imageName}}.png"/>
Hope this helps
Upvotes: 0
Reputation: 1276
With webpack, you can bundle assets with CopyWebpackPlugin. Have a look at this webpack.config.js, it uses assets. https://github.com/BlueForestTrees/web/blob/master/webpack.config.js
Inside plugins section:
new CopyWebpackPlugin([{from: './img', to: 'img'}]),
Upvotes: 0