美文网首页
vue常用插件

vue常用插件

作者: 两年半练习程序员 | 来源:发表于2019-03-20 16:45 被阅读0次

Vuex

npm install vuex --save
//vue add vuex

//main.js
import Vue from 'vue'
import App from './App.vue'
import store from './store'

new Vue({
  store,
  render: h => h(App)
}).$mount('#app')

router

npm install vue-router
//vue add vue add router

//main.js
import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')

echarts

npm install echarts --save

import echarts from 'echarts';


this.chart = echarts.init(this.$el);
this.chart.setOption(options);

jquery

npm install jquery --save

//package.json 文件内的 "dependencies"中检查是否有 "jquery": "^3.3.1", (如没有 则需手动添加)

//vue.config.js文件里面配一配
//在vue.config.js的文件开头添加:
const webpack = require('webpack');
//module.exports中,添加:
configureWebpack: {
    plugins: [
        new webpack.ProvidePlugin({
            $:"jquery",
 
            jQuery:"jquery",
            "windows.jQuery":"jquery"
        })
    ]
},

bootstrap

npm install bootstrap --save

<style lang="scss">
@import '~bootstrap/scss/bootstrap';
</style>

element-ui

npm i element-ui -S

//main.js
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

Vue.use(ElementUI);

scss

npm install -D sass-loader node-sass

vue-lazyload

$ npm install vue-lazyload --save

//main.js
import VueLazyload from 'vue-lazyload'
 
Vue.use(VueLazyload)
// or with options
Vue.use(VueLazyload, {
  preLoad: 1.3,
  error: 'dist/error.png',
  loading: 'dist/loading.gif',
  attempt: 1
})

导入所有组件

// 导入所有组件
const componentsReq = require.context('./components', true, /\.vue$/);
componentsReq.keys().forEach((key) => {
  const component = componentsReq(key).default;
  Vue.component(component.name, component);
});
mouse.png

相关文章

  • Vue 插件

    插件,通常用来为Vue 添加全局功能。引用官方文档Vue插件 使用插件 通过全局方法Vue.user()使用插件。...

  • plugin插件

    插件通常用来为 Vue 添加全局功能。 直接使用别人开发好的插件:Vue.use() 自己开发插件: Vue.js...

  • 优雅注册按需加载的插件(个人笔记)

    本文来自:优雅注册插件 插件通常用来为 Vue 添加全局功能。像常用的 vue-router、vuex 在使用时都...

  • Vue.js

    Target 01.常用插件:vue-awesome-swiper轮播图插件、 ***路由插件Router:基础:...

  • vue知识整理

    # Vue.js - day01 ## 插件安装推荐 vscode有二个常用插件:vetur,Vue 2 Snip...

  • 如何开发和发布一个Vue插件

    Vue 项目开发过程中,经常用到插件,比如原生插件 vue-router 、 vuex ,还有 element-u...

  • 03.vue-ajax、vue UI 组件库

    vue-ajax vue 项目中常用的 2 个 ajax 库 vue-resource: vue 插件, 非官方...

  • Vue.use是干什么的?原理是什么?

    Vue.use()是用来使用插件的。 插件的作用:插件通常用来为Vue添加全局功能,插件的功能没有严格的限制,一般...

  • 什么是vue插件,vue插件怎么使用?

    一、什么是vue插件 官方解释 插件通常用来为 Vue 添加全局功能。插件的功能范围没有严格的限制——一般有下面几...

  • Vue-ajax

    vue 项目中常用的 2 个 ajax 库 1、 vue-resourcevue 插件, 非官方库, vue1.x...

网友评论

      本文标题:vue常用插件

      本文链接:https://www.haomeiwen.com/subject/vurtvqtx.html