iview按需引入时报错
These dependencies were not found:
* iview/dist/styles/iview.css in ./src/main.js
* iview/src/components/button in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/components/HelloWorld.vue
To install them, you can run: npm install --save iview/dist/styles/iview.css iview/src/components/button
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'
import { Button } from 'iview'
import 'iview/dist/styles/iview.css'
Vue.config.productionTip = false
Vue.component('Button', Button)
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
components: { App },
template: '<App/>'
})
.babelrc
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime", [
"import", {
"libraryName": "iview",
"libraryDirectory": "src/components"
}
]]
}
Hello.vue
<template>
<div class="hello">
<Button type="primary">Primary</Button>
</div>
</template>
- 我是按照最新的官方api来引入的,下面的插件已经引入了
npm install babel-plugin-import --save-dev
麻烦看下什么原因,谢谢~
我这边自己弄好了,代码没问题,问题我没npm install iview,傻逼了,打扰各位。