当前位置:Gxlcms > JavaScript > 在vue2.0中有哪些常用的UI库?

在vue2.0中有哪些常用的UI库?

时间:2021-07-01 10:21:17 帮助过:7人阅读

这篇文章主要介绍了vue2.0 常用的 UI 库实例讲解,非常不错,具有参考借鉴价值,需要的朋友可以参考下

1.mint-ui

安装:

  1. npm install mint-ui --save

使用:

main.js

  1. // MintUI组件库
  2. import MintUI from 'mint-ui'
  3. import 'mint-ui/lib/style.css'
  4. Vue.use(MintUI)

2.vux

安装:

  1. npm install vux --save
  2. npm install vux-loader --save

使用:

vux2必须配合vux-loader使用, 请在build/webpack.base.conf.js里参照如下代码进行配置:

  1. build / webpack.base.conf.js
  2. const vuxLoader = require('vux-loader')
  3. const webpackConfig = originalConfig // 原来的 module.exports 代码赋值给变量 webpackConfig
  4. module.exports = vuxLoader.merge(webpackConfig, {
  5. plugins: ['vux-ui']
  6. })

实例:webpack.base.conf.js

  1. 'use strict'
  2. const path = require('path')
  3. const utils = require('./utils')
  4. const config = require('../config')
  5. const vueLoaderConfig = require('./vue-loader.conf')
  6. // 添加 vux-loader
  7. const vuxLoader = require('vux-loader')
  8. function resolve (dir) {
  9. return path.join(__dirname, '..', dir)
  10. }
  11. // 原来的 module.exports 代码赋值给变量 webpackConfig
  12. const webpackConfig = {
  13. entry: {
  14. app: './src/main.js'
  15. },
  16. output: {
  17. path: config.build.assetsRoot,
  18. filename: '[name].js',
  19. publicPath: process.env.NODE_ENV === 'production'
  20. ? config.build.assetsPublicPath
  21. : config.dev.assetsPublicPath
  22. },
  23. resolve: {
  24. extensions: ['.js', '.vue', '.json'],
  25. alias: {
  26. 'vue$': 'vue/dist/vue.esm.js',
  27. '@': resolve('src'),
  28. }
  29. },
  30. module: {
  31. rules: [
  32. {
  33. test: /\.vue$/,
  34. loader: 'vue-loader',
  35. options: vueLoaderConfig
  36. },
  37. {
  38. test: /\.js$/,
  39. loader: 'babel-loader',
  40. include: [resolve('src'), resolve('test')]
  41. },
  42. {
  43. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  44. loader: 'url-loader',
  45. options: {
  46. limit: 10000,
  47. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  48. }
  49. },
  50. {
  51. test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
  52. loader: 'url-loader',
  53. options: {
  54. limit: 10000,
  55. name: utils.assetsPath('media/[name].[hash:7].[ext]')
  56. }
  57. },
  58. {
  59. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  60. loader: 'url-loader',
  61. options: {
  62. limit: 10000,
  63. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  64. }
  65. }
  66. ]
  67. }
  68. }
  69. // 扩展
  70. module.exports = vuxLoader.merge(webpackConfig, {
  71. plugins: ['vux-ui']
  72. })

3.weex-ui

安装:

  1. npm install weex-ui --save

使用:

为了不打包所有的组件,你需要使用 babel-plugin-component 来只引入需要的组件打包。

  1. npm i babel-plugin-component -D

.babelrc

  1. // 增加一个plugins的配置到 .babelrc 中
  2. {
  3. "plugins": [
  4. [
  5. "component",
  6. {
  7. "libraryName": "weex-ui",
  8. "libDir": "packages"
  9. }
  10. ]
  11. ]
  12. }

上面是我整理给大家的,希望今后会对大家有帮助。

相关文章:

使用javascript如何实现数字配对游戏

在vue.js中如何调用vuex储存接口数据

在JavaScript中如何实现全选取消效果

使用JavaScript如何实现左侧菜单效果

以上就是在vue2.0中有哪些常用的 UI 库?的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行