最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue監(jiān)聽(tīng)用戶(hù)輸入和點(diǎn)擊功能

 更新時(shí)間:2019年09月27日 12:00:43   作者:小羽向前跑  
這篇文章主要為大家詳細(xì)介紹了vue監(jiān)聽(tīng)用戶(hù)輸入和點(diǎn)擊功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue監(jiān)聽(tīng)用戶(hù)輸入和點(diǎn)擊的具體代碼,供大家參考,具體內(nèi)容如下

功能1:監(jiān)聽(tīng)用戶(hù)輸入和點(diǎn)擊,并實(shí)時(shí)顯示,

功能2:點(diǎn)擊發(fā)布,編輯頁(yè)面隱藏,顯示發(fā)布成功。

功能1 html代碼:

使用:v-model監(jiān)聽(tīng),!submmited視圖默認(rèn)顯示,注意監(jiān)聽(tīng)option v-for="(i,index) in authors"   v-bind:value="authors[index],

監(jiān)聽(tīng)當(dāng)下用戶(hù)點(diǎn)擊的那個(gè);

 <div id="add-blog">
  <h2>添加博客</h2>
  <form v-if="!submmited">
  <label for="" class="">博客標(biāo)題</label>
  <input class="" type="text" v-model="blog.title" required/>
  <br/>
  <label for="" class="">博客內(nèi)容</label>
  <textarea class="" v-model="blog.content"></textarea>
  <div id="checkboxs">
   <label for="">Vue.js</label>
   <input type="checkbox" value="vue.js" v-model="blog.categories"/>
   <label for="">react.js</label>
   <input type="checkbox" value="react.js" v-model="blog.categories"/>
   <label for="">javasript</label>
   <input type="checkbox" value="javasript.js" v-model="blog.categories"/>
   <label for="">css</label>
   <input type="checkbox" value="css" v-model="blog.categories"/>
  </div>
  <label for="">作者:</label>
  <select v-model="blog.author">
   <option v-for="(i,index) in authors" v-bind:value="authors[index]">
   {{i}}
   </option>
  </select>
  <button v-on:click.prevent="post">添加博客</button>
  </form>
  <hr/>
  <div id="preview">
  <h3>博客總覽</h3>
  <p>博客標(biāo)題:</p>
  <p class="color">{{blog.title}}</p>
  <p>博客內(nèi)容:</p>
  <p class="color">{{blog.content}}</p>
  <p>博客分類(lèi)</p>
  <ul>
   <li v-for="categories in blog.categories" class="color">
   {{categories}}
   </li>
  </ul>
  <p>作者:</p>
  <p class="color">{{blog.author}}</p>
  </div>
 </div>

 功能1 js代碼:

data(){
   return{
   blog:{
    title:"",
    content:"",
    categories:[],
    author:""
   },
   authors:[
    "張三","李四","王五"
   ],
   submmited:false
   }
  },
 methods:{
   post:function () {
   this.$http.post("https://jsonplaceholder.typicode.com/posts/"{
    title:this.blog.title,
    body:this.blog.content,
})
   .then(function (data) {
    //console.log(data);
   })
   }
  }

功能2 html代碼:

 <div v-if="submmited">
  <h3>您的博客發(fā)布成功</h3>
 </div>

功能2 js代碼

this.submmited=true 讓 “您的博客發(fā)布成功” 顯示

methods:{
   post:function () {
   this.$http.post("https://jsonplaceholder.typicode.com/posts/"{
    title:this.blog.title,
    body:this.blog.content,
})
   .then(function (data) {
    //console.log(data);
    this.submmited=true
   })
   }
  }

addblog.vue所有代碼:

<template>
 <div id="add-blog">
  <h2>添加博客</h2>
  <form v-if="!submmited">
  <label for="" class="">博客標(biāo)題</label>
  <input class="" type="text" v-model="blog.title" required/>
  <br/>
  <label for="" class="">博客內(nèi)容</label>
  <textarea class="" v-model="blog.content"></textarea>
  <div id="checkboxs">
   <label for="">Vue.js</label>
   <input type="checkbox" value="vue.js" v-model="blog.categories"/>
   <label for="">react.js</label>
   <input type="checkbox" value="react.js" v-model="blog.categories"/>
   <label for="">javasript</label>
   <input type="checkbox" value="javasript.js" v-model="blog.categories"/>
   <label for="">css</label>
   <input type="checkbox" value="css" v-model="blog.categories"/>
  </div>
  <label for="">作者:</label>
  <select v-model="blog.author">
   <option v-for="(i,index) in authors" v-bind:value="authors[index]">
   {{i}}
   </option>
  </select>
  <button v-on:click.prevent="post">添加博客</button>
  </form>
  <div v-if="submmited">
  <h3>您的博客發(fā)布成功</h3>
  </div>
  <hr/>
  <div id="preview">
  <h3>博客總覽</h3>
  <p>博客標(biāo)題:</p>
  <p class="color">{{blog.title}}</p>
  <p>博客內(nèi)容:</p>
  <p class="color">{{blog.content}}</p>
  <p>博客分類(lèi)</p>
  <ul>
   <li v-for="categories in blog.categories" class="color">
   {{categories}}
   </li>
  </ul>
  <p>作者:</p>
  <p class="color">{{blog.author}}</p>
  </div>
 </div>
</template>
 
<script>
 export default {
  name: "addblog",
  data(){
   return{
   blog:{
    title:"",
    content:"",
    categories:[],
    author:""
   },
   authors:[
    "張三","李四","王五"
   ],
   submmited:false
   }
  },
  methods:{
   post:function () {
   this.$http.post("https://jsonplaceholder.typicode.com/posts/",this.blog)
   .then(function (data) {
    console.log(data);
    this.submmited=true
   })
   }
  }
 }
</script>
 
<style scoped>
#add-blog *{
 box-sizing: border-box;
}
#add-blog{
 margin: 20px auto;
 max-width: 600px;
 padding:20px;
}
 label{
 display: block;
 margin:20px 0 10px;
 }
 input[type="text"],textarea,select{
 display: block;
 width: 100%;
 padding: 8px;
 }
 textarea{
 height: 200px;
 }
 #checkboxs label{
 display: inline-block;
 margin-top: 0;
 }
 #checkboxs input{
 display: inline-block;
 margin-right: 10px;
 }
 button{
 display: block;
 margin:20px 0;
 background: crimson;
 border:0;
 padding:14px;
 border-radius: 4px;
 font-size: 18px;
 cursor: pointer;
 color: white;
 }
 #preview{
 padding:10px 20px;
 border: 1px dotted #ccc;
 margin:30px 0;
 }
 .color{
 color: blue;
 }
</style>

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

相關(guān)文章

  • vue3獲取、設(shè)置元素高度的代碼舉例

    vue3獲取、設(shè)置元素高度的代碼舉例

    這篇文章主要給大家介紹了關(guān)于vue3獲取、設(shè)置元素高度的相關(guān)資料,小編通過(guò)實(shí)際案例向大家展示操作過(guò)程,操作方法簡(jiǎn)單易懂,需要的朋友可以參考下
    2024-08-08
  • Vuex實(shí)現(xiàn)簡(jiǎn)單購(gòu)物車(chē)

    Vuex實(shí)現(xiàn)簡(jiǎn)單購(gòu)物車(chē)

    這篇文章主要為大家詳細(xì)介紹了Vuex實(shí)現(xiàn)簡(jiǎn)單購(gòu)物車(chē),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-01-01
  • 對(duì)vux點(diǎn)擊事件的優(yōu)化詳解

    對(duì)vux點(diǎn)擊事件的優(yōu)化詳解

    今天小編就為大家分享一篇對(duì)vux點(diǎn)擊事件的優(yōu)化詳解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-08-08
  • vue中v-for通過(guò)動(dòng)態(tài)綁定class實(shí)現(xiàn)觸發(fā)效果

    vue中v-for通過(guò)動(dòng)態(tài)綁定class實(shí)現(xiàn)觸發(fā)效果

    這篇文章主要介紹了vue中v-for通過(guò)動(dòng)態(tài)綁定class實(shí)現(xiàn)觸發(fā)效果,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-12-12
  • 解決vue-photo-preview 異步圖片放大失效的問(wèn)題

    解決vue-photo-preview 異步圖片放大失效的問(wèn)題

    這篇文章主要介紹了解決vue-photo-preview 異步圖片放大失效的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-07-07
  • Vue3+Vite4項(xiàng)目進(jìn)行性能優(yōu)化的配置方案

    Vue3+Vite4項(xiàng)目進(jìn)行性能優(yōu)化的配置方案

    這篇文章主要為大家詳細(xì)介紹了Vue3如何結(jié)合Vite4對(duì)項(xiàng)目進(jìn)行性能優(yōu)化的相關(guān)配置,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2025-04-04
  • 解決Can''t find variable: SockJS vue項(xiàng)目的問(wèn)題

    解決Can''t find variable: SockJS vue項(xiàng)目的問(wèn)題

    這篇文章主要介紹了解決Can't find variable: SockJS vue項(xiàng)目的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-09-09
  • 一篇文章帶你徹底搞懂VUE響應(yīng)式原理

    一篇文章帶你徹底搞懂VUE響應(yīng)式原理

    這篇文章主要介紹了一篇文章帶你徹底搞懂VUE響應(yīng)式原理,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可任意參考一下,需要的朋友可以參考下
    2022-06-06
  • 深入理解vue-router之keep-alive

    深入理解vue-router之keep-alive

    本篇文章主要介紹了深入理解vue-router之keep-alive。keep-alive使被包含的組件保留狀態(tài),或避免重新渲染,有興趣的可以了解一下
    2017-08-08
  • Vue使用video標(biāo)簽實(shí)現(xiàn)視頻播放

    Vue使用video標(biāo)簽實(shí)現(xiàn)視頻播放

    這篇文章主要為大家詳細(xì)介紹了Vue使用video標(biāo)簽實(shí)現(xiàn)視頻播放,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-09-09

最新評(píng)論

邢台县| 马鞍山市| 宕昌县| 田东县| 郧西县| 庐江县| 松江区| 孟连| 彰武县| 塔河县| 呼伦贝尔市| 桦甸市| 吴桥县| 五家渠市| 迭部县| 双鸭山市| 赤水市| 华安县| 临潭县| 南安市| 新巴尔虎右旗| 五大连池市| 文山县| 呼玛县| 南开区| 郓城县| 普安县| 汉中市| 巨鹿县| 韶山市| 瓮安县| 奈曼旗| 夏津县| 班戈县| 洛隆县| 永康市| 姜堰市| 云霄县| 岗巴县| 汶川县| 柳江县|