内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

微信小程序Page中data數(shù)據(jù)操作和函數(shù)調(diào)用的方法-創(chuàng)新互聯(lián)

這篇“微信小程序Page中data數(shù)據(jù)操作和函數(shù)調(diào)用的方法”文章的知識(shí)點(diǎn)大部分人都不太理解,所以小編給大家總結(jié)了以下內(nèi)容,內(nèi)容詳細(xì),步驟清晰,具有一定的借鑒價(jià)值,希望大家閱讀完這篇文章能有所收獲,下面我們一起來(lái)看看這篇“微信小程序Page中data數(shù)據(jù)操作和函數(shù)調(diào)用的方法”文章吧。

目前創(chuàng)新互聯(lián)已為近1000家的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬主機(jī)、網(wǎng)站托管維護(hù)、企業(yè)網(wǎng)站設(shè)計(jì)、佛坪網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。

微信小程序 詳解Page中data數(shù)據(jù)操作和函數(shù)調(diào)用

Page() 函數(shù)用來(lái)注冊(cè)一個(gè)頁(yè)面。接受一個(gè) object 參數(shù),其指定頁(yè)面的初始數(shù)據(jù)、生命周期函數(shù)、事件處理函數(shù)等。

//index.js 
<pre code_snippet_id="2049407" snippet_file_name="blog_20161214_1_1145312" name="code" class="javascript">Page({ 
 data: { 
  text: "This is page data.",</pre><pre code_snippet_id="2049407" snippet_file_name="blog_20161214_2_861121" name="code" class="javascript">  sliderOffset: 0, 
  sliderLeft: 0, 
  state:{ 
     genre:[], 
     genre_index: 0, 
     model:[], 
     model_index: 0, 
     terminalStatus:'', 
  } 
 }, 
 onLoad: function(options) { 
  // Do some initialize when page load. 
 }, 
 onReady: function() { 
  // Do something when page ready. 
 }, 
 onShow: function() { 
  // Do something when page show. 
 }, 
 onHide: function() { 
  // Do something when page hide. 
 }, 
 onUnload: function() { 
  // Do something when page close. 
 }, 
 onPullDownRefresh: function() { 
  // Do something when pull down. 
 }, 
 onReachBottom: function() { 
  // Do something when page reach bottom. 
 }, 
 // Event handler. 
 viewTap: function () { 
  var p = this.position 
  ball(p, 150) 
  function ball(x, y) { 
   console.log(x,y) 
  } 
 }, 
 customData: { 
  hi: 'MINA' 
 } 
})</pre><br> 
<p></p> 
<pre></pre> 
<br> 
1、設(shè)置data數(shù)據(jù) 
<p></p> 
<p><span style="font-size:14px">setData 函數(shù)用于將數(shù)據(jù)從邏輯層發(fā)送到視圖層,同時(shí)改變對(duì)應(yīng)的 this.data 的值。<br> 
注意:<br> 
(1)、直接修改 this.data 無(wú)效,無(wú)法改變頁(yè)面的狀態(tài),還會(huì)造成數(shù)據(jù)不一致。<br> 
(2)、單次設(shè)置的數(shù)據(jù)不能超過(guò)1024kB,請(qǐng)盡量避免一次設(shè)置過(guò)多的數(shù)據(jù)。<br> 
</span></p> 
<p><span style="font-size:14px">setData() 參數(shù)格式:接受一個(gè)對(duì)象,以 key,value 的形式表示將 this.data 中的 key 對(duì)應(yīng)的值改變成 value。其中 key 可以非常靈活,以數(shù)據(jù)路徑的形式給出,如 array[2].message,a.b.c.d,并且不需要在 this.data 中預(yù)先定義。<br> 
</span></p> 
<p><span style="font-size:14px">下面設(shè)置data中的text和genre_index的值</span></p> 
<p><span style="font-size:14px"></span></p><pre code_snippet_id="2049407" snippet_file_name="blog_20161214_3_1831450" name="code" class="html">this.setData({ 
   'state.genre_index':1, 
   text:'data value' 
})</pre><p></p> 
<p>2、獲取data數(shù)據(jù)</p> 
<p>獲取data中的text和genre_index值需要使用this</p> 
<p></p><pre code_snippet_id="2049407" snippet_file_name="blog_20161214_4_5833420" name="code" class="javascript"><pre code_snippet_id="2049407" snippet_file_name="blog_20161214_4_5833420" name="code" class="javascript">var gener_index=this.data.state.genre_index</pre><pre code_snippet_id="2049407" snippet_file_name="blog_20161214_5_8406932" name="code" class="javascript">var text=this.data.text</pre><p></p> 
<pre></pre> 
3、調(diào)用viewTap函數(shù) 
<p></p> 
<p>在viewTap函數(shù)中調(diào)用內(nèi)部的ball函數(shù)可以直接調(diào)用,如果需要在onReady函數(shù)中調(diào)用viewTap函數(shù)需要使用this。</p> 
<p></p><pre code_snippet_id="2049407" snippet_file_name="blog_20161214_6_6869005" name="code" class="html">onReady: function () { 
  this.drawBall() 
 },</pre><br> 
<br> 
<br> 
<p></p> 
<br> 
   
</pre>

以上就是關(guān)于“微信小程序Page中data數(shù)據(jù)操作和函數(shù)調(diào)用的方法”這篇文章的內(nèi)容,相信大家都有了一定的了解,希望小編分享的內(nèi)容對(duì)大家有幫助,若想了解更多相關(guān)的知識(shí)內(nèi)容,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

網(wǎng)頁(yè)題目:微信小程序Page中data數(shù)據(jù)操作和函數(shù)調(diào)用的方法-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)URL:http://www.rwnh.cn/article2/ddopic.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、移動(dòng)網(wǎng)站建設(shè)、軟件開(kāi)發(fā)外貿(mào)網(wǎng)站建設(shè)、微信公眾號(hào)商城網(wǎng)站

廣告

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

成都網(wǎng)頁(yè)設(shè)計(jì)公司
开原市| 高密市| 广河县| 德兴市| 略阳县| 松原市| 洛宁县| 乌兰浩特市| 汾西县| 饶河县| 靖边县| 洪湖市| 荃湾区| 昆山市| 娱乐| 台南县| 南通市| 恩平市| 融水| 沁源县| 米林县| 巴南区| 砚山县| 东兴市| 如皋市| 安陆市| 乃东县| 阿鲁科尔沁旗| 化隆| 盐亭县| 株洲县| 曲沃县| 怀集县| 潍坊市| 浏阳市| 苏州市| 托克逊县| 苍溪县| 竹溪县| 奇台县| 马龙县|