欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue實(shí)現(xiàn)簡(jiǎn)易選項(xiàng)卡功能

 更新時(shí)間:2022年06月24日 16:11:05   作者:顧舟  
這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)簡(jiǎn)易選項(xiàng)卡功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue實(shí)現(xiàn)簡(jiǎn)易選項(xiàng)卡功能的具體代碼,供大家參考,具體內(nèi)容如下

1. 效果:

1. 實(shí)現(xiàn)發(fā)布評(píng)論功能

2. 實(shí)現(xiàn)評(píng)論列表的展示

3. 使用標(biāo)簽頁(yè)切換的方式來(lái)實(shí)現(xiàn)

4. 高亮顯示當(dāng)前標(biāo)簽頁(yè)欄對(duì)應(yīng)的導(dǎo)航

2.HTML

<div id="app">
? ? ? ? <p>
? ? ? ? ? ? <button @click="tab(0)" :class="current===0?'active':''">評(píng)論管理</button>
? ? ? ? ? ? <button @click="tab(1)" :class="current===1?'active':''">發(fā)布評(píng)論</button>
? ? ? ? </p>
? ? ? ? <div class="box2" v-show="current===0">
? ? ? ? ? ? <div v-for="item in list">
? ? ? ? ? ? ? ? <p>評(píng)論人:{{item.username}}</p>
? ? ? ? ? ? ? ? <p>評(píng)論時(shí)間:{{item.time}}</p>
? ? ? ? ? ? ? ? <p>評(píng)論內(nèi)容:{{item.content}}</p>
? ? ? ? ? ? </div>
? ? ? ? </div>
? ? ? ? <div class="box1" v-show="current===1">
? ? ? ? ? ? <input v-model="username" type="text" placeholder="昵稱"><br>
? ? ? ? ? ? <input v-model="content" type="text" placeholder="評(píng)論內(nèi)容"><br>
? ? ? ? ? ? <button @click="submit">立即提交</button>
? ? ? ? </div>
</div>

3.CSS

<style>
? ? ? ? #app div {
? ? ? ? ? ? width: 600px;
? ? ? ? ? ? font-size: 14px;
? ? ? ? ? ? box-sizing: border-box;
? ? ? ? }
?
? ? ? ? .box1 {
? ? ? ? ? ? height: 200px;
? ? ? ? ? ? padding: 20px 0 0 10px;
? ? ? ? ? ? background: #eee;
? ? ? ? }
?
? ? ? ? .box2>div {
? ? ? ? ? ? height: 200px;
? ? ? ? ? ? padding: 20px 0 0 10px;
? ? ? ? ? ? background: #eee;
? ? ? ? ? ? margin-bottom: 10px;
? ? ? ? }
?
? ? ? ? p button {
? ? ? ? ? ? width: 100px;
? ? ? ? ? ? height: 35px;
? ? ? ? ? ? border: none;
? ? ? ? ? ? background: #e1e1e1;
? ? ? ? }
?
? ? ? ? p button.active {
? ? ? ? ? ? background: blue;
? ? ? ? ? ? color: #fff;
? ? ? ? }
?
? ? ? ? .box1 input {
? ? ? ? ? ? width: 350px;
? ? ? ? ? ? height: 35px;
? ? ? ? ? ? outline: none;
? ? ? ? ? ? border: 1px solid #ccc;
? ? ? ? ? ? margin-bottom: 10px;
? ? ? ? ? ? border-radius: 5px;
? ? ? ? ? ? box-sizing: border-box;
? ? ? ? }
?
? ? ? ? .box1 button {
? ? ? ? ? ? width: 80px;
? ? ? ? ? ? height: 35px;
? ? ? ? ? ? border: none;
? ? ? ? ? ? border-radius: 5px;
? ? ? ? ? ? background: #e1e1e1;
? ? ? ? }
</style>

4.引入vue.js文件

<script src="vue.js"></script>

5.實(shí)現(xiàn)發(fā)布評(píng)論選項(xiàng)卡功能

// 創(chuàng)建Vue的實(shí)例化對(duì)象
? ? new Vue({
? ? ? ? data: {
? ? ? ? ? ? // 控制選項(xiàng)卡切換
? ? ? ? ? ? current: 1,
? ? ? ? ? ? // 與輸入框進(jìn)行數(shù)據(jù)綁定
? ? ? ? ? ? username: '',
? ? ? ? ? ? content: '',
? ? ? ? ? ? // 創(chuàng)建評(píng)論管理列表數(shù)據(jù)
? ? ? ? ? ? list: []
? ? ? ? },
? ? ? ? methods: {
? ? ? ? ? ? // 點(diǎn)擊提交按鈕
? ? ? ? ? ? submit() {
? ? ? ? ? ? ? ? // 創(chuàng)建當(dāng)前時(shí)間
? ? ? ? ? ? ? ? let date = new Date();
? ? ? ? ? ? ? ? let year = date.getFullYear();
? ? ? ? ? ? ? ? let mon = date.getMonth() + 1;
? ? ? ? ? ? ? ? let day = date.getDate();
? ? ? ? ? ? ? ? let time = year + "-" + mon + '-' + day;
? ? ? ? ? ? ? ? // 創(chuàng)建評(píng)論對(duì)象
? ? ? ? ? ? ? ? const infor = {
? ? ? ? ? ? ? ? ? ? username: this.username,
? ? ? ? ? ? ? ? ? ? content: this.content,
? ? ? ? ? ? ? ? ? ? time
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? // 將評(píng)論對(duì)象追加到評(píng)論管理的列表末尾
? ? ? ? ? ? ? ? this.list.push(infor);
? ? ? ? ? ? ? ? //重置input輸入框的內(nèi)容
? ? ? ? ? ? ? ? this.username = '';
? ? ? ? ? ? ? ? this.content = "";
? ? ? ? ? ? },
? ? ? ? ? ? // 點(diǎn)擊評(píng)論管理按鈕、發(fā)布評(píng)論按鈕(實(shí)現(xiàn)選項(xiàng)卡)
? ? ? ? ? ? tab(index) {
? ? ? ? ? ? ? ? this.current = index;
? ? ? ? ? ? }
? ? ? ? }
? ? }).$mount("#app");

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 淺談element關(guān)于table拖拽排序問(wèn)題

    淺談element關(guān)于table拖拽排序問(wèn)題

    本文主要介紹了element關(guān)于table拖拽排序問(wèn)題,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-10-10
  • vue 頁(yè)面回退mounted函數(shù)不執(zhí)行的解決方案

    vue 頁(yè)面回退mounted函數(shù)不執(zhí)行的解決方案

    這篇文章主要介紹了vue 頁(yè)面回退mounted函數(shù)不執(zhí)行的解決方案 ,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-07-07
  • Nuxt使用Vuex的方法示例

    Nuxt使用Vuex的方法示例

    這篇文章主要介紹了Nuxt使用Vuex的方法示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-09-09
  • Vue自定義詢問(wèn)彈框和輸入彈框的示例代碼

    Vue自定義詢問(wèn)彈框和輸入彈框的示例代碼

    這篇文章主要介紹了Vue自定義詢問(wèn)彈框和輸入彈框,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-06-06
  • vue3下watch的使用方法示例

    vue3下watch的使用方法示例

    vue3中的watch是一個(gè)組合式的API使用時(shí)需要引入,下面這篇文章主要給大家介紹了關(guān)于vue3下watch使用的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-03-03
  • 聊聊vue生命周期鉤子函數(shù)有哪些,分別什么時(shí)候觸發(fā)

    聊聊vue生命周期鉤子函數(shù)有哪些,分別什么時(shí)候觸發(fā)

    這篇文章主要介紹了聊聊vue生命周期鉤子函數(shù)有哪些,分別什么時(shí)候觸發(fā)?具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-04-04
  • 一文徹底搞懂Vue中scoped和/deep/原理

    一文徹底搞懂Vue中scoped和/deep/原理

    在Vue中,有兩種常用的CSS選擇器,用于修改組件樣式:scoped?和?/deep/(或?::v-deep),它們都是為了實(shí)現(xiàn)樣式的作用域,本文小編就來(lái)分別給大家介紹一下這兩種選擇器的原理,需要的朋友可以參考下
    2023-08-08
  • 解決vue項(xiàng)目運(yùn)行出現(xiàn)warnings?potentially?fixable?with?the?`--fix`?option的報(bào)錯(cuò)問(wèn)題

    解決vue項(xiàng)目運(yùn)行出現(xiàn)warnings?potentially?fixable?with?the?`--fix

    這篇文章主要介紹了解決vue項(xiàng)目運(yùn)行出現(xiàn)warnings?potentially?fixable?with?the?`--fix`?option的報(bào)錯(cuò)問(wèn)題,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2021-11-11
  • Vue 2.0的數(shù)據(jù)依賴實(shí)現(xiàn)原理代碼簡(jiǎn)析

    Vue 2.0的數(shù)據(jù)依賴實(shí)現(xiàn)原理代碼簡(jiǎn)析

    本篇文章主要介紹了Vue 2.0的數(shù)據(jù)依賴實(shí)現(xiàn)原理代碼簡(jiǎn)析,主要從初始化的數(shù)據(jù)層面上分析了Vue是如何管理依賴來(lái)到達(dá)數(shù)據(jù)的動(dòng)態(tài)響應(yīng),有興趣的可以了解一下
    2017-07-07
  • vue中設(shè)置滾動(dòng)條方式

    vue中設(shè)置滾動(dòng)條方式

    這篇文章主要介紹了在vue中設(shè)置滾動(dòng)條的方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-08-08

最新評(píng)論