欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

vue.jsinput框之間賦值方法

如下所示:

網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)!專(zhuān)注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、微信小程序開(kāi)發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶(hù)創(chuàng)新互聯(lián)還提供了江陵免費(fèi)建站歡迎大家使用!

demo.html

<!DOCTYPE html>
<html>
 
<head>
 <meta charset="utf-8">
 <title>Index Page</title>
</head>
 
<body>
 <form action="" id="demo">
 <input type="text" value="調(diào)試 vuejs 2.0" ref="input1">
 <a href="javascript:void(0)" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" v-on:click="test1">測(cè)試</a>
 <br>
 <span>{{ result1 }}</span>
 <br>
 
 <input type="text" v-model="input2">
 <a href="javascript:void(0)" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" v-on:click="test2">測(cè)試</a>
 <br>
 <span>{{ result2 }}</span>
 </form>
 
 <script src="http://cdn.bootcss.com/vue/2.0.3/vue.min.js"></script>
 <script type="text/javascript" src="demo.js"></script>
</body>
 
</html>

demo.js

new Vue({
 el: "#demo",
 
 data: {
  result1: null,
  result2: null,
  input2: ""
 },
 
 
 
 methods: {
  test1: function () {
   this.result1 = this.$refs.input1.value + " 成功!";
  },
 
  test2: function () {
   this.result2 = this.input2 + " 成功!";
  }
 }
})

demo.html

<!DOCTYPE html>
<html>
 
<head>
 <meta charset="utf-8">
 <title>Index Page</title>
</head>
 
<body>
 <form action="" id="demo">
 <input type="text" value="調(diào)試 vuejs 2.0" ref="input1">
 <a href="javascript:void(0)" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" v-on:click="test1">測(cè)試</a>
 <br>
 <span>{{ result1 }}</span>
 <br>
 
 <input type="text" v-model="input2">
 <a href="javascript:void(0)" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" v-on:click="test2">測(cè)試</a>
 <br>
 <span>{{ result2 }}</span>
 </form>
 
 <script src="http://cdn.bootcss.com/vue/2.0.3/vue.min.js"></script>
 <script type="text/javascript" src="demo.js"></script>
</body>
 
</html>

拓展知識(shí):初試Vue之元素、屬性賦值方法

我們?cè)趘ue中數(shù)據(jù)賦值時(shí),會(huì)很自然而然的想到用“Mustache” 雙大括號(hào)插值法來(lái)賦值

在一個(gè)小案例中,比如給一個(gè)img標(biāo)簽附上鏈接  會(huì)很自然的想到

<img src={{img.path}} />

運(yùn)行時(shí)會(huì)很自然的發(fā)現(xiàn)文件資源請(qǐng)求失敗,究其因很簡(jiǎn)單,因?yàn)閟rc是屬性而不是值,故不可直接src={{ img.path }}

當(dāng)然,Vue的 v-bind 已經(jīng)為我們考慮完備了

官方文檔對(duì)于v-bind的說(shuō)明:動(dòng)態(tài)地綁定一個(gè)或多個(gè)特性,或一個(gè)組件 prop 到表達(dá)式。在綁定 class 或 style 特性時(shí),支持其它類(lèi)型的值,如數(shù)組或?qū)ο蟆?梢酝ㄟ^(guò)下面的教程鏈接查看詳情。

傳送門(mén):v-bind官方說(shuō)明

注意點(diǎn):在普通文本可直接使用雙大括號(hào)法賦值,但對(duì)于標(biāo)簽的屬性最好還是用v-bind來(lái)賦值,測(cè)了下,input 輸入框的 value 和 placeholder 是可以使用雙大括號(hào)法的。但是為了避免異議,還是遵循官方文檔給的要求,給屬性賦值時(shí)用v-bind吧。

以上這篇vue.js input框之間賦值方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持創(chuàng)新互聯(lián)。

文章標(biāo)題:vue.jsinput框之間賦值方法
鏈接地址:http://chinadenli.net/article32/jhjisc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站網(wǎng)站建設(shè)域名注冊(cè)搜索引擎優(yōu)化標(biāo)簽優(yōu)化企業(yè)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)