Mint UI組件庫(kù)CheckList使用及踩坑總結(jié)
Import
按需引入:
import { Checklist } from 'mint-ui';
Vue.component(Checklist.name, Checklist);
全局導(dǎo)入:全局導(dǎo)入后不用再導(dǎo)入
importMintfrom'mint-ui' import'mint-ui/lib/style.css' Vue.use(Mint);
API

示例
示例一:
xxx.vue:
<template>
<div id="app">
<mt-checklist
v-model="value"
:options="options">
</mt-checklist>
</div>
</template>
<script>
export default {
name: 'app',
data () {
return {
//存放所選選項(xiàng)
value:[],
//checklist設(shè)置
options : [{
label: '選項(xiàng)A',
value: 'A',
disabled: true //可以禁用選項(xiàng)
},
{
label: '選項(xiàng)B',
value: 'B',
disabled: true
},
{
label: '選項(xiàng)C',
value: 'C'
},
{
label: '選項(xiàng)D',
value: 'D'
}]
}
},
mounted:function(){
}
}
</script>
<style>
</style>
show:

示例二:
xxx.vue:
<template>
<div id="app">
<mt-checklist
title="復(fù)選框列表"
v-model="value"
align="right"
:options="options" @change="checkon">
</mt-checklist>
</div>
</template>
<script>
export default {
name: 'app',
data () {
return {
//存放所選選項(xiàng)
value:[],
//checklist設(shè)置
options : [{
label: '選項(xiàng)A',
value: 'A'
},
{
label: '選項(xiàng)B',
value: 'B'
},
{
label: '選項(xiàng)C',
value: 'C'
},
{
label: '選項(xiàng)D',
value: 'D'
}]
}
},
mounted:function(){
},
methods:{
checkon: function(){
console.log(this.value)
}
}
}
</script>
<style>
</style>
show:

點(diǎn)擊“選項(xiàng)B”

所選擇內(nèi)容是

再點(diǎn)擊“選項(xiàng)C”

所選擇內(nèi)容是

demo鏈接:mint-ui-checklist_jb51.rar
使用前輸入命令:
npm install npm run dev
在開(kāi)發(fā)過(guò)程中,我們肯定遇到過(guò)這樣的問(wèn)題,如下圖所示:

我選擇了兩個(gè)選項(xiàng),但是v-model中綁定的數(shù)組只有一個(gè),解決這個(gè)問(wèn)題如下代碼
<template>
<mt-checklist :title="多選標(biāo)題" v-model="value" :options="item.options" @change="checkon($event)"></mt-checklist>
</template>
<script>
export default {
name: 'app',
data () {
return {
value: [],
questionName: '多選標(biāo)題1',
options: [{
label: '玩具1',
remark: '',
seq: 1,
value: '2ea0bbe02e024b76aa0180d5332a2d68'
},
{
label: '玩具2',
remark: '',
seq: 1,
value: '2ea0bbe02e024b76aa0180d5332a2d69'
},
{
label: '玩具3',
remark: '',
seq: 1,
value: '2ea0bbe02e024b76aa0180d5332a2d70'
}]
}
},
methods: {
checkon (item) {
console.log(item)
}
}
}
</script>
只需在change事件中加$event, 然后打印參數(shù)就是合適的,如圖

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
ElementUI實(shí)現(xiàn)在下拉列表里面進(jìn)行搜索功能詳解
有時(shí)候需要用到下拉列表全選和搜索,下面這篇文章主要給大家介紹了關(guān)于ElementUI實(shí)現(xiàn)在下拉列表里面進(jìn)行搜索功能的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-04-04
vite+vue3項(xiàng)目集成ESLint與prettier的過(guò)程詳解
這篇文章主要介紹了vite+vue3項(xiàng)目中集成ESLint與prettier的相關(guān)知識(shí),本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-09-09
vue elementui簡(jiǎn)易側(cè)拉欄的使用小結(jié)
這篇文章主要介紹了vue elementui簡(jiǎn)易側(cè)拉欄的使用,增加了側(cè)拉欄,目的是可以選擇多條數(shù)據(jù)展示數(shù)據(jù),本文通過(guò)示例代碼給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧2024-06-06
Vue3?<script?setup?lang=“ts“>?的基本使用
<script setup>?是在單文件組件 (SFC) 中使用?composition api?的編譯時(shí)語(yǔ)法糖,本文主要講解<script setup>?與?TypeScript?的基本使用,感興趣的朋友跟隨小編一起看看吧2022-12-12
如何配置vue.config.js 處理static文件夾下的靜態(tài)文件
這篇文章主要介紹了如何配置vue.config.js 處理static文件夾下的靜態(tài)文件,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-06-06
Vue3實(shí)現(xiàn)登錄表單驗(yàn)證功能
這篇文章主要介紹了Vue3實(shí)現(xiàn)登錄表單驗(yàn)證功能,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-06-06

