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

html中如何用vue語(yǔ)法,并使用UI組件庫(kù) ,html中引入vue+ant-design-vue或者vue+element-plus

這篇具有很好參考價(jià)值的文章主要介紹了html中如何用vue語(yǔ)法,并使用UI組件庫(kù) ,html中引入vue+ant-design-vue或者vue+element-plus。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

html中如何用vue語(yǔ)法,并使用UI組件庫(kù)

前言
先說(shuō)一下本次應(yīng)用的場(chǎng)景,本次項(xiàng)目中,需要引入github中別人寫(xiě)好的插件,插件比較大,沒(méi)有方法直接在自己項(xiàng)目中,把別人的項(xiàng)目打包合并生成html(類似于前端項(xiàng)目打包生成的 dist ),修改這里面的html,這種情況要么用原生js寫(xiě)或者jquery還相對(duì)快一些,那為什么不直接用vue語(yǔ)法呢?哈哈哈,下面就教你怎么寫(xiě)。


首先你要有vue3對(duì)應(yīng)的js文件和antd組件庫(kù)對(duì)應(yīng)的文件,要么就用cdn

vue3 + ant-design-vue

這里用antDesignVue4.0
直接上代碼,相信你可以看懂的
注意看 ant-design-vue官網(wǎng)
html中如何用vue語(yǔ)法,并使用UI組件庫(kù) ,html中引入vue+ant-design-vue或者vue+element-plus,Vue,前端技巧方法,vue.js,anti-design-vue,elementui,vue,前端

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue3語(yǔ)法模板</title>
    <script src="https://unpkg.com/vue@next"></script>
    <!-- <link rel="stylesheet"  />
    <script src="https://unpkg.com/element-plus"></script> -->

    <script src="https://unpkg.com/dayjs/dayjs.min.js"></script>
    <script src="https://unpkg.com/dayjs/plugin/customParseFormat.js"></script>
    <script src="https://unpkg.com/dayjs/plugin/weekday.js"></script>
    <script src="https://unpkg.com/dayjs/plugin/localeData.js"></script>
    <script src="https://unpkg.com/dayjs/plugin/weekOfYear.js"></script>
    <script src="https://unpkg.com/dayjs/plugin/weekYear.js"></script>
    <script src="https://unpkg.com/dayjs/plugin/advancedFormat.js"></script>
    <script src="https://unpkg.com/dayjs/plugin/quarterOfYear.js"></script>
    <link rel="stylesheet" type="text/css" href="./ant/antd.reset.css" media="screen">
    <script src="./ant/antd.js"></script>
</head>
<style>
</style>

<body>
    <div style="width:100%;" id="app">
        <div>{{exp_id}}</div>
        <div>{{fullNum}}</div>
        <div v-for="item in dateTime" :key="item">{{item}}</div>
        <a-button type="primary" @click="upload('更新')">更新</a-button>
        <a-button type="dashed" @click="sets('恢復(fù)')">恢復(fù)</a-button>
        <a-button danger @click="dialog">打開(kāi)彈框</a-button>
        <div>
            <a-select v-model="value" class="m-2" placeholder="Select" size="large">
                <a-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
            </a-select>
        </div>
       
    </div>
</body>

</html>
<script>
    Object.assign(window, Vue);
    const vue3Composition = {
        setup() {
            // 變量部分
            const data = reactive({
                exp_id: '虛擬實(shí)驗(yàn)id',
                dateTime: [1, 2, 3, 4, 5],
                value: '',
                dialogVisible: false,
                options: [{
                        value: 'Option1',
                        label: 'Option1',
                    },
                    {
                        value: 'Option2',
                        label: 'Option2',
                    }
                ]
            });
            // toRef: 復(fù)制 reactive 里的單個(gè)屬性并轉(zhuǎn)成 ref
            // toRefs: 復(fù)制 reactive 里的所有屬性并轉(zhuǎn)成 ref
            const dataRef = toRefs(data)
            // 監(jiān)聽(tīng)
            watch(dataRef.exp_id, (newName, oldName) => {
                console.log("新數(shù)據(jù)", newName);
                console.log("老數(shù)據(jù)", oldName);
            })
            // 計(jì)算屬性
            dataRef.fullNum = computed(() => {
                return dataRef.value
            });
            // 生命周期 mounted
            onMounted(() => {
                console.log(`我是Mounted生命周期`)
            })
            // 函數(shù)部分
            const methods = reactive({
                upload(e) {
                    dataRef.exp_id.value = '修改'
                    dataRef.dateTime.value = [8, 9, 10, 11, 12]
                    //this.dialog() //調(diào)用其他方法加this可以調(diào)用到
                },
                sets(e) {
                    dataRef.exp_id.value = '虛擬實(shí)驗(yàn)id'
                    dataRef.dateTime.value = [1, 2, 3, 4, 5]
                },
                dialog() {
                    dataRef.dialogVisible.value = true
                }
            })
            return {
                ...dataRef,
                ...methods
            }
        },
    }
    const app = createApp(vue3Composition).use(antd).mount("#app");//初始化
</script>

vue2 + element-plus

這里對(duì)應(yīng)的vuejs我下載到本地了,自己去cdn上面找一個(gè)就好了文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-692277.html

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue2語(yǔ)法模板</title>
    <!-- <script src="https://unpkg.com/vue@next"></script>
    <link rel="stylesheet"  />
    <script src="https://unpkg.com/element-plus"></script> -->
    <script src="./vue2/vue2.js"></script>
    <script src="./vue2/element-ui/index.js"></script>
    <link rel="stylesheet" href="./vue2/element-ui/index.css" />
</head>
<style>
</style>

<body>
    <div style="width:100%;" id="app">
        <div>{{activeType}}</div>
        <div>{{fullNum}}</div>
        <div v-for="item in dateTime" :key="item">{{item}}</div>
        <el-button type="primary" @click="upload('更新')">更新</el-button>
        <el-button type="success" @click="sets('恢復(fù)')">恢復(fù)</el-button>
        <el-button type="warning" @click="dialog">打開(kāi)彈框</el-button>
        <div>
            <el-select v-model="value" class="m-2" placeholder="Select" size="large">
                <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
        </div>
    </div>
</body>

</html>
<script>
    new Vue({
        el: '#app',
        data() {
            return {
                //左邊菜品類別index
                activeType: 0,
                categoryList: [],
                categoryId: undefined,
            }
        },
        computed: {

        },
        created() {
        },
        watch: {

        },
        mounted() {
            this.initData()
        },
        methods: {




        }
    })

</script>

vue3 + element-plus

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue3語(yǔ)法模板</title>
    <script src="https://unpkg.com/vue@next"></script>
    <link rel="stylesheet" href="https://unpkg.com/element-plus/dist/index.css" />
    <script src="https://unpkg.com/element-plus"></script>
</head>
<style>
</style>

<body>
    <div style="width:100%;" id="app">
        <div>{{exp_id}}</div>
        <div>{{fullNum}}</div>
        <div v-for="item in dateTime" :key="item">{{item}}</div>
        <el-button type="primary" @click="upload('更新')">更新</el-button>
        <el-button type="success" @click="sets('恢復(fù)')">恢復(fù)</el-button>
        <el-button type="warning" @click="dialog">打開(kāi)彈框</el-button>
        <div>
            <el-select v-model="value" class="m-2" placeholder="Select" size="large">
                <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
        </div>
        <el-dialog v-model="dialogVisible" title="Tips" width="30%">
            <span>This is a message</span>
            <template #footer>
                <span class="dialog-footer">
                    <el-button @click="dialogVisible = false">Cancel</el-button>
                    <el-button type="primary" @click="dialogVisible = false">
                        Confirm
                    </el-button>
                </span>
            </template>
        </el-dialog>
    </div>
</body>

</html>
<script>
    Object.assign(window, Vue);
    const vue3Composition = {
        setup() {
            // 變量部分
            const data = reactive({
                exp_id: '虛擬實(shí)驗(yàn)id',
                dateTime: [1, 2, 3, 4, 5],
                value: '',
                dialogVisible: false,
                options: [{
                        value: 'Option1',
                        label: 'Option1',
                    },
                    {
                        value: 'Option2',
                        label: 'Option2',
                    }
                ]
            });
            // toRef: 復(fù)制 reactive 里的單個(gè)屬性并轉(zhuǎn)成 ref
            // toRefs: 復(fù)制 reactive 里的所有屬性并轉(zhuǎn)成 ref
            const dataRef = toRefs(data)
            // 監(jiān)聽(tīng)
            watch(dataRef.exp_id, (newName, oldName) => {
                console.log("新數(shù)據(jù)", newName);
                console.log("老數(shù)據(jù)", oldName);
            })
            // 計(jì)算屬性
            dataRef.fullNum = computed(() => {
                return dataRef.value
            });
            // 生命周期 mounted
            onMounted(() => {
                console.log(`我是Mounted生命周期`)
            })
            // 函數(shù)部分
            const methods = reactive({
                upload(e) {
                    dataRef.exp_id.value = '修改'
                    dataRef.dateTime.value = [8, 9, 10, 11, 12]
                    //this.dialog() //調(diào)用其他方法加this可以調(diào)用到
                },
                sets(e) {
                    dataRef.exp_id.value = '虛擬實(shí)驗(yàn)id'
                    dataRef.dateTime.value = [1, 2, 3, 4, 5]
                },
                dialog() {
                    dataRef.dialogVisible.value = true
                }
            })
            return {
                ...dataRef,
                ...methods
            }
        },
    }
    const app = createApp(vue3Composition).use(ElementPlus).mount("#app");//初始化
</script>

到了這里,關(guān)于html中如何用vue語(yǔ)法,并使用UI組件庫(kù) ,html中引入vue+ant-design-vue或者vue+element-plus的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

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

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

相關(guān)文章

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

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

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包