使用Vue + Webpack加载图像

时间:2018-10-17 18:36:54

标签: javascript html5 vue.js webpack

我正在尝试:

<img src="./src/assets/logo.png"></img>

或者这个

background-image: url("./src/assets/logo.png");

我已经完成了npm install url-loader@1.1.1的安装 npm安装文件加载器--save-dev。

但是我收到了这个消息

* ./src/assets/logo.png in ./node_modules/vue-loader/lib/template-compiler?{"id":"data-v-219927dc","hasScoped":true,"transformToRequire":{"video":["src","poster"],"source":"src","img":"src","image":"xlink:href"},"buble":{"transforms":{}}}!./node_modules/vue-loader/lib/selector.js?type=template&index=0!./src/view/login/Login.vue

1 个答案:

答案 0 :(得分:1)

我假设您的vue组件和css文件位于 src 目录中,对吗?在这种情况下,您需要将网址更改为

public abstract class Writer {
public static void write() {System.out.println("Writing...");}
}
public class Author extends Writer {
public static void write() {System.out.println("Writing book");}
}
public class Programmer extends Writer {
public static void write() {System.out.println("Writing code");}
public static void main(String[] args) {
Writer w = new Programmer();
w.write();
}
}

public abstract class Writer {
public void write() {System.out.println("Writing...");}
}
public class Author extends Writer {
public void write() {System.out.println("Writing book");}
}
public class Programmer extends Writer {
public void write() {System.out.println("Writing code");}
public static void main(String[] args) {
Writer w = new Programmer();
w.write();
}
}