the directory structure is as follows
1. I try to put pictures directly into index.html, using the absolute path in static can be achieved, but loading pictures in assets is not good, and the relative path is useless, how to achieve html files if you want to load pictures in assets directly.
2. And app, is mounted in main.js
import tImg from "./assets/logo.png"
new Vue({
router,
data(){
return {
imgUrl:"./assets/logo.png"
// imgUrl:tImg
}
},
mounted(){
console.log(tImg)
},
template: `
<div id="app">
<h1>Route props</h1>
<img src="${tImg}">
<img src="${this.imgUrl}">//,imgUrl
<img src="./assets/logo.png">//
<img src="../static/logo.png">
<router-view class="view" foo="123"></router-view>
</div>
`
}).$mount("-sharpapp")
if you don"t need a string template, you can directly refer to the image relative to the path and transfer it to base64. But with the above string template, neither the path in data nor the direct relative path can find the picture. Is there something wrong with my writing?
the vue-cli I used directly in the config configuration file has not changed.