国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

【Vue框架】Vue2中element-ui/mint-ui組件庫——element-ui引入組件以及使用案例、mint-ui引入組件及使用案例

這篇具有很好參考價(jià)值的文章主要介紹了【Vue框架】Vue2中element-ui/mint-ui組件庫——element-ui引入組件以及使用案例、mint-ui引入組件及使用案例。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

一、element-ui/mint-ui組件庫

element-ui 提供了大量的組件,如:布局組件、表單組件、JS組件等等。

1.1 element-ui使用步驟

Element-ui官網(wǎng):https://element.eleme.cn/#/zh-CN
mintui組件,NodeJs,vue.js,javascript,Mint-ui,Vue2,Element-ui
安裝 Element-ui:npm i element-ui -S
mintui組件,NodeJs,vue.js,javascript,Mint-ui,Vue2,Element-ui

1.1.1 引入組件

引入 Element

  • 完整引入(在 main.js 中寫入以下內(nèi)容):
import Vue from 'vue';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App.vue';

Vue.use(ElementUI);

new Vue({
  el: '#app',
  render: h => h(App)
});
  • 按需引入

借助 babel-plugin-component,我們可以只引入需要的組件,以達(dá)到減小項(xiàng)目體積的目的。
首先,安裝 babel-plugin-component: npm install babel-plugin-component -D
然后,將 .babelrc 修改為:

{
  "presets": [["es2015", { "modules": false }]],
  "plugins": [
    [
      "component",
      {
        "libraryName": "element-ui",
        "styleLibraryName": "theme-chalk"
      }
    ]
  ]
}

接下來,如果你只希望引入部分組件,比如 Button 和 Select,那么需要在 main.js 中寫入以下內(nèi)容:

import Vue from 'vue';
import { Button, Select } from 'element-ui';
import App from './App.vue';

Vue.component(Button.name, Button);
Vue.component(Select.name, Select);
/* 或?qū)憺? * Vue.use(Button)
 * Vue.use(Select)
 */

new Vue({
  el: '#app',
  render: h => h(App)
});

1.1.2 修改 .babelrc文件

{
  "presets": [
    ["env", {
      "modules": false,
      "targets": {
        "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
      }
    }],
    "stage-2"
  ],
  "plugins": [
    "transform-vue-jsx",
    "transform-runtime",
    [
      "component",
        {
          "libraryName": "element-ui",
          "styleLibraryName": "theme-chalk"
        }
    ]
  ]
}

mintui組件,NodeJs,vue.js,javascript,Mint-ui,Vue2,Element-ui

1.2 mint-ui的使用

Mint UI官網(wǎng): http://mint-ui.github.io/#!/zh-cn
mintui組件,NodeJs,vue.js,javascript,Mint-ui,Vue2,Element-ui

1.2.1 安裝引入組件

1、安裝組件

// 安裝
# Vue 1.x
npm install mint-ui@1 -S
# Vue 2.0
npm install mint-ui -S

mintui組件,NodeJs,vue.js,javascript,Mint-ui,Vue2,Element-ui

2、引入組件

  • 完整引入

在 main.js 中寫入以下內(nèi)容:

import Vue from 'vue'
import MintUI from 'mint-ui'
import 'mint-ui/lib/style.css'
import App from './App.vue'

Vue.use(MintUI)

new Vue({
  el: '#app',
  components: { App }
})
  • 按需引入

借助 babel-plugin-component,我們可以只引入需要的組件,以達(dá)到減小項(xiàng)目體積的目的。
首先,安裝 babel-plugin-component: npm install babel-plugin-component -D

{
  "presets": [
    ["es2015", { "modules": false }]
  ],
  "plugins": [["component", [
    {
      "libraryName": "mint-ui",
      "style": true
    }
  ]]]
}

mintui組件,NodeJs,vue.js,javascript,Mint-ui,Vue2,Element-ui

如果你只希望引入部分組件,比如 Button 和 Cell,那么需要在 main.js 中寫入以下內(nèi)容:
需要引入樣式:import 'mint-ui/lib/style.css';

// 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'

// 1、引入Element-ui組件
// import { Button } from 'element-ui';
// Vue.use(Button)

// 2、引入Mint-ui組件
import 'mint-ui/lib/style.css';
import {Button} from 'mint-ui';
Vue.component(Button.name, Button);

Vue.config.productionTip = false  //設(shè)置在控制臺(tái)環(huán)境進(jìn)行代碼提示作用

// 1.全局路由守衛(wèi)
router.beforeEach((to,from,next) => {
  /*
    to:表示要去的新頁面
    from:表示舊的頁面
    next:表示是否
  */
  // 0——表示未登錄
  // 1——表示已登錄
  var islogin = 1;
  if(to.meta.needAuth){
    if(islogin == 0){
      router.push({name:'login'})
    }
    if(islogin == 1){
      next()
    }
  }else{
    next()
  }
})

// 2.全局過濾器
Vue.filter('toFixed1',function(val,data,data1){
  return data1 + val.toFixed(data)
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})

1.2.2 Mint-ui相關(guān)組件

官網(wǎng)文檔: https://mint-ui.github.io/docs/#/zh-cn2
mintui組件,NodeJs,vue.js,javascript,Mint-ui,Vue2,Element-ui
HelloWorld.vue

<template>
  <div class="hello">

      <mt-button type="danger" @click="myToast">danger</mt-button>

      <hr>
      <el-button type="primary">主要按鈕</el-button>

      <hr>
      <router-link to="/mydetail">產(chǎn)品詳情</router-link>
      <router-link to="/mycar">購物車</router-link>
      <router-link to="/myorder">下單頁面</router-link>

      <hr>
      <button @click="mytab">點(diǎn)擊</button>

      <hr/>
      <router-link to="/tab">選項(xiàng)卡</router-link>

      <hr/>
      <myslot>
        <div slot="name1">
          {{msg}}
        </div>
        <div slot="name2">
          {{num}}
        </div>
      </myslot>

      <hr/>
      <input type="text" placeholder="請輸入用戶名" v-model="t1"/>
      <input type="text" placeholder="請輸入密碼" v-model="t2"/>
      <button :class="{active:isTrue}">登錄</button>

      <hr/>
      <input type="text" name="" id="" v-model="num3"/>

      <hr/>
      <input type="text" placeholder="請輸入用戶名" v-model="user"/>
      <input type="text" placeholder="請輸入密碼" v-model="password"/>
      <button :class="{active:getActive}">登錄</button>
      <h1>{{getAvg}}</h1>
      <h1>{{getSum}}</h1>
      <h1>{{num | toFixed(5,"$")}}</h1>
      <h1>{{num1 | toFixed1(5,"$")}}</h1>
      <h1>{{msg}}</h1>
  </div>
</template>

<script>
import { Toast } from 'mint-ui';
import myslot from './02slot';

export default {
  name: 'HelloWorld',
  data () {
    return {
      num:10,
      num1:20,
      num3:100,
      msg: 'Welcome to Your Vue.js App',
      user:'',
      password:'',
      isTrue:false,
      t1:'',
      t2:'',
    }
  },
  filters:{
    toFixed(val,data,data1){
      return data1 + val.toFixed(data)
    }
  },
  computed:{
    getSum(){
      return this.num + this.num1;
    },
    getAvg(){
      return this.getSum/2;
    },
    getActive(){
      if(this.user==''||this.password==''){
        return false
      }
      return true
    }
  },
  watch:{
    num3(){
      console.log("num3修改了")
    },
    t1(){
      if(this.t1 == '' || this.t2 ==''){
        this.isTrue = false
      }else{
        this.isTrue = true
      }
    },
    t2(){
      if(this.t1 == '' || this.t2 ==''){
        this.isTrue = false
      }else{
        this.isTrue = true
      }
    }
  },
  components:{
    myslot,
  },
  methods:{
    mytab(){
      //鏈?zhǔn)铰酚商D(zhuǎn)
      this.$router.push({
        // 方式一
        // name:'tab'
        // 方式二
        path:'/tab',
        query:{
          id:100
        }
      })
    },
    myToast(){
      Toast({
        message: '提示',
        position: 'center',
        duration: 5000
      });
    }
  },
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
	.active{
	  color: red;
	}
	h1, h2 {
	  font-weight: normal;
	}
	ul {
	  list-style-type: none;
	  padding: 0;
	}
	li {
	  display: inline-block;
	  margin: 0 10px;
	}
	a {
	  color: #42b983;
	}
</style>

mintui組件,NodeJs,vue.js,javascript,Mint-ui,Vue2,Element-ui文章來源地址http://www.zghlxwxcb.cn/news/detail-734319.html

到了這里,關(guān)于【Vue框架】Vue2中element-ui/mint-ui組件庫——element-ui引入組件以及使用案例、mint-ui引入組件及使用案例的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • mint-ui使用,web開發(fā)技術(shù)發(fā)展

    mint-ui使用,web開發(fā)技術(shù)發(fā)展

    下載到本地。 放在assets 中 main.js引入 import ‘@/assets/icon/iconfont.css’ swipe 1 2 3 參數(shù): :show-indicators=“false” 隱藏焦點(diǎn) :auto=“0” 取消輪播 @change=“handleChange” 輪播圖片觸發(fā)的函數(shù),參數(shù)為切入輪播圖的索引 methods: { handleChange(index) { … } } tabbar 底部導(dǎo)航 外賣 訂單 發(fā)現(xiàn) 我的 d

    2024年04月26日
    瀏覽(24)
  • Vue2自己封裝的基礎(chǔ)組件庫或基于Element-ui再次封裝的基礎(chǔ)組件庫,如何發(fā)布到npm并使用(支持全局或按需引入使用),超詳細(xì)

    Vue2自己封裝的基礎(chǔ)組件庫或基于Element-ui再次封裝的基礎(chǔ)組件庫,如何發(fā)布到npm并使用(支持全局或按需引入使用),超詳細(xì)

    以下我以 wocwin-admin-vue2 項(xiàng)目為例 修改目錄結(jié)構(gòu),最終如下 1、導(dǎo)入組件,組件必須聲明 name 2、定義 install 方法,接收 Vue 作為參數(shù)。如果使用 use 注冊插件,則所有的組件都將被注冊 3、導(dǎo)出的對象必須具有 install,才能被 Vue.use() 方法安裝(全局使用) 4、按需引入 5、packa

    2024年02月08日
    瀏覽(36)
  • Vue2.0安裝Element-ui

    Vue2.0安裝Element-ui

    1.在項(xiàng)目終端輸入 如果想知道是否安裝成功 ? 2.隨后在main.js里引入element組件 然后去使用element ? 就這樣成功了 ?

    2024年02月16日
    瀏覽(19)
  • Vue2 +Element-ui實(shí)現(xiàn)前端頁面

    Vue2 +Element-ui實(shí)現(xiàn)前端頁面

    以一個(gè)簡單的前端頁面為例。主要是利用vue和element-ui實(shí)現(xiàn)。 里面涉及的主要包括:新建vue項(xiàng)目、一行多個(gè)輸入框、頁面實(shí)現(xiàn)等。 ? ①首先安裝nodejs,這部分在此就不講啦。 ②然后安裝vue-cli: 查看是否安裝成功: 安裝成功之后就輸出vue的版本 ③在cmd窗口新建一個(gè)vue2腳手架

    2024年02月16日
    瀏覽(33)
  • vue2+element-ui實(shí)現(xiàn)側(cè)邊導(dǎo)航欄

    編寫 client/src/components/LeftMenu.vue ,創(chuàng)建側(cè)邊導(dǎo)航欄: 編輯 client/src/views/Index.vue ,引入側(cè)邊導(dǎo)航欄:

    2024年02月02日
    瀏覽(30)
  • vue2+element-ui 實(shí)現(xiàn)國際化

    在src目錄下創(chuàng)建一個(gè)lang文件夾,同時(shí)創(chuàng)建zh.js(中文),en.js(英文),ja.js(日文),fr.js(法文)四個(gè)語言包js文件,并創(chuàng)建一個(gè)index.js文件,用來整合語言包 對于一個(gè)項(xiàng)目來說,一個(gè)語言包需要包含所有頁面以及組件;在語言包以頁面為單位,創(chuàng)建一個(gè)對象;對公共的title或者按鈕名

    2024年02月02日
    瀏覽(30)
  • VUE2+Element-ui+封裝Echarts圖表

    VUE2+Element-ui+封裝Echarts圖表

    封裝Echarts圖表,如下效果圖 Home組件代碼塊,使用的mock.js模擬數(shù)據(jù)封裝 Echarts圖表組件 安裝所需依賴 cnpm i axios -S 安裝axios接口請求 cnpm i mockjs 或 yarn add mockjs 安裝mockjs生成模擬隨機(jī)數(shù)據(jù) cnpm i echarts 或 yarn add echarts 安裝echarts圖表 cnpm i element-ui -S 安裝element-ui組件庫 安裝less c

    2024年02月08日
    瀏覽(28)
  • vue2&Element-ui實(shí)現(xiàn)表格單元格合并

    vue2&Element-ui實(shí)現(xiàn)表格單元格合并

    由于項(xiàng)目需要實(shí)現(xiàn)單元格合并目前只是單頁沒有做分頁處理先上效果圖 看下數(shù)據(jù)結(jié)構(gòu) Element table提供的api arraySpanMethod columnIndex=0表示從第一列開始 rowIndex表示需要操作的行數(shù) 同濟(jì)醫(yī)院加上合計(jì)有12行從0開始=11 判斷條件是rowIndex余12===0 我們打印一下 或者改成 表示從0開始到1

    2024年02月12日
    瀏覽(37)
  • Vue2+element-ui后臺(tái)管理系統(tǒng)(靜態(tài)頁面)

    Vue2+element-ui后臺(tái)管理系統(tǒng)(靜態(tài)頁面)

    node:https://nodejs.org/en/ git:https://git-scm.com/ vue:https://v2.cn.vuejs.org/v2/guide/installation.html element-ui:https://element.eleme.cn/#/zh-CN/component/installation 項(xiàng)目所需:https://pan.baidu.com/s/1ua0jp9YCtPH6slE49HDUBw 提取碼:kkkk 在node和vue都調(diào)試、配置好的情況下使用vscode 在終端中輸入命令 npm i -g @vue

    2024年02月06日
    瀏覽(43)
  • element-ui vue2 iframe 嵌入外鏈新解

    element-ui vue2 iframe 嵌入外鏈新解

    src/views/IFrame/IFrame.vue · 朝雨憶輕塵(Louis)/kitty-ui - Gitee.com Vue 路由組件傳參的 8 種方式 - 掘金

    2024年02月08日
    瀏覽(24)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包