【发布时间】:2017-10-02 17:03:58
【问题描述】:
我是 vue js 的新手,正在努力学习这一点。我在我的系统中安装了一个全新版本的 vue webpack。我有一个 css、js 和这个主题模板的图像,我想将它们包含到 HTML 中,所以我尝试将它添加到 index.html,但我可以在控制台中看到错误并且资产没有被添加。当我搜索时,我知道我可以在main.js 文件中使用require。但我得到了错误:
按照我在main.js 文件中的尝试:
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
require('./assets/styles/vendor.css');
require('./assets/styles/main.css');
require('./assets/scripts/vendor/modernizr.js');
Vue.config.productionTip = false
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
template: '<App/>',
components: { App }
})
虽然我尝试使用 import 来使用它,但仍然出现错误
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import('./assets/styles/vendor.css')
// require('./assets/styles/vendor.css');
// require('./assets/styles/main.css');
// require('./assets/scripts/vendor/modernizr.js');
Vue.config.productionTip = false
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
template: '<App/>',
components: { App }
})
帮我解决这个问题。
【问题讨论】:
-
你从哪里安装 vue webpack?主题模板从何而来?你用的是什么编辑器?
-
@user1585345 我通过
vue-cli安装了vue,我们有一个html template,它在css 文件中有样式表。我正在为WebStorm编辑工作
标签: webpack vue.js vuejs2 webpack-dev-server