我是 vue js 新手,正在尝试学习这个。我在我的系统中安装了全新版本的 vue webpack。我有一个 css、js 和这个主题模板的图像,我想将其包含到 HTML 中,所以我尝试将其添加到index.html
但我可以在控制台中看到错误,并且未添加资产。当我搜索时,我开始知道我可以使用require
in main.js
文件。但我收到错误:
以下我已经尝试过main.js
file:
// 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 }
})
Here is the error screenshot:
帮我解决这个问题。
您可以在 App.vue 上的 style 标签内导入 css 文件。
<style>
@import './assets/styles/yourstyles.css';
</style>
另外,如果需要的话,请确保安装了正确的加载程序。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)