Introduction of iview on demand

iview introduces Times error on demand

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: "-sharpapp",
  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>
  • I introduced it in accordance with the latest official api, and the following plug-ins have introduced
npm install babel-plugin-import --save-dev

could you please see what the reason is? thank you ~

Mar.28,2021

clipboard.png

clipboard.png
import button, is not installed
generally direct import iView from 'iview'; and then install iview, all its components are available without introducing one by one


I've done it by myself, the code is fine, I don't have a npm install iview, stupid, excuse me.


is it installed using iview cli

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31913-2bdd1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31913-2bdd1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?