as shown in the picture, I have a common style.css under static and want to introduce a picture file in assets. How to write url is not correct after trying for a long time. (
as shown in the picture, I have a common style.css under static and want to introduce a picture file in assets. How to write url is not correct after trying for a long time. (
background: url(../assets/img/sprite-1.jpg)
just use the relative path. How to use it before or how to use it now
<img src="@/assets/img/bg@2x.png" >
<i :style="`background-image: url(${require('@/assets/img/bg@2x.png')});`" />
or
<img :src="passport" >
<script>
export default {
data() {
return {
passport: require('@/assets/img/bg@2x.png'),
}
},
}
</scipt>
.demo{
background-image: url("~@/assets/img/bg@2x.png");
}
if you want to use static
instead of assets
, Please refer to: https://github.com/vuejs/vue-.
vue-cli has already configured the src directory. How do you need to find the relative directory and look up at the first level? the upper level directory of your style.css is css,css 's parent directory is static,. Obviously, the directory src is not under static. Of course, can not be found, I hope you can help you
static directory under the picture also put in the static directory, use the relative path can
I remember I was using the background way to introduce the background image in the path can not have'-', change your picture name to sprite_1.png try
excuse me, have you solved the problem? How did you solve it?
the new version is also recommended to be put into assets, so it's better to package
if you use vue-cli, the code under the static folder will not be compiled, what url in css is packaged or what, the assets code and images under src will be processed, and the packaging path depends on the assetsRoot,assetsSubDirectory parameters you configure. There is no assets folder after packaging, and the static folder is copied without processing.
now you need to change the style of an element on the page based on the current route when the page jumps to a route. Boss, don t just talk about ideas, but also talk about the specific implementation code. I am relatively bad, a lot of grammar is not ...
recently, I have been learning to use vue to build a small mobile project, in which vue-router; is used. What is the component structure of clicking the navigation button at the bottom and then jumping to a different page, but the bottom navigation will...
recently contacted vue, to use vue to make a similar style website (as shown below), and the actual demand is estimated to be 20 + pages visually. Can a single page be satisfied? because I haven t used vue, I worry that when using a single page, ...
I found that beforeEach, the vue navigation guard, can verify login permissions, so is there no need for axios interceptors? I hope the bosses will tell us what you think. or rather, the axios interceptor is sufficient, and there is no need for vue navi...
it is normal to start the server and enter 192.168.0.21purl 8080 in the browser, but when I jump to another routing page to refresh, the page reports a 404 error. I looked up a lot of information that said it was caused by html5 s history, but I didn ...
when the vue routing page is switched, the picture on ios is reloaded every time (the picture is a web link picture) the picture will still be reloaded when it is hidden on the page IOS will not have this problem with Android < hr > ...
I use vue-router to load lazily. Why are some of the packaged files so large? for example, this 2 contains other js? in 2.js * . How to divide them the above is analyzed by webpack-bundle-analyzer. Please take a look at it for me ...
the vue project runs normally in chrome or edge and can be redirected normally. if you execute this.$router.push in IE11, you will report Loading chunk 0 failed . babel-polyfill has been added, but it s still the same problem. is there any...
vue-cli project version update, there is a strange phenomenon. Enter a link to a page directly in the browser and have been updated to the new version. At this time, if you click logo to get to the home page, and then go back to the previous link, the in...
vue-cli project version update, there is a strange phenomenon. Enter a link to a page directly in the browser and have been updated to the new version. At this time, if you click logo to get to the home page, and then go back to the previous link, the in...