www.2016338.comBackboneJSmodel.changed

VIM ww9992019com 发表于 5 天前

www.2016338.com开户请拨15974937077深圳被砸男童去世西安临潼区Yt9MSA<div style="width:100%;float:left;" class="article-content">

                <input type="hidden" name="article_id" id="article_id" value="7320">
                <input type="hidden" name="catid" id="catid" value="0">

                <p>

它使用set()方法设置的属性后已更改的属性。</p>

<h2>

语法</h2>

<pre courier new monospace padding:>

model.changed
</pre>

<h2>

示例</h2>

<pre class="prettyprint tryit prettyprinted" courier new monospace border-radius: width: line-height: font-size: overflow: auto color: rgb cursor: default background-image: url background-attachment: initial background-size: background-origin: background-clip: background-position: background-repeat: no-repeat>

<span class="dec">&lt;!DOCTYPE html&gt;</span><span class="pln">

</span><span class="tag">&lt;head&gt;</span><span class="pln">

  </span><span class="tag">&lt;title&gt;</span><span class="pln"> Model Example</span><span class="tag">&lt;/title&gt;</span><span class="pln">

     </span><span class="tag">&lt;script</span><span class="pln"> </span><span class="atn">src</span><span class="pun">=</span><span class="atv">"https://code.jquery.com/jquery-2.1.3.min.js"</span><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="tag">&gt;&lt;/script&gt;</span><span class="pln">

     </span><span class="tag">&lt;script</span><span class="pln"> </span><span class="atn">src</span><span class="pun">=</span><span class="atv">"https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js"</span><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="tag">&gt;&lt;/script&gt;</span><span class="pln">

     </span><span class="tag">&lt;script</span><span class="pln"> </span><span class="atn">src</span><span class="pun">=</span><span class="atv">"https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"</span><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="tag">&gt;&lt;/script&gt;</span><span class="pln">

     </span><span class="tag">&lt;script</span><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"text/javascript"</span><span class="tag">&gt;</span><span class="pln">

        </span><span class="typ">Player</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Backbone</span><span class="pun">.</span><span class="typ">Model</span><span class="pun">.</span><span class="pln">extend</span><span class="pun">({</span><span class="pln">

        defaults</span><span class="pun">:</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

           p_name</span><span class="pun">:</span><span class="pln"> </span><span class="str">'sachin'</span><span class="pun">,</span><span class="pln">

           country</span><span class="pun">:</span><span class="pln"> </span><span class="str">'india'</span><span class="pln">

        </span><span class="pun">},</span><span class="pln">

        initialize</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

           </span><span class="kwd">this</span><span class="pun">.</span><span class="pln">bind</span><span class="pun">(</span><span class="str">"change:p_name"</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">(</span><span class="pln">model</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

              </span><span class="kwd">var</span><span class="pln"> name </span><span class="pun">=</span><span class="pln"> model</span><span class="pun">.</span><span class="kwd">get</span><span class="pun">(</span><span class="str">"p_name"</span><span class="pun">);</span><span class="pln">

              </span><span class="kwd">var</span><span class="pln"> ctry </span><span class="pun">=</span><span class="pln"> model</span><span class="pun">.</span><span class="kwd">get</span><span class="pun">(</span><span class="str">"country"</span><span class="pun">);</span><span class="pln">

           </span><span class="pun">});</span><span class="pln">

       </span><span class="pun">}</span><span class="pln">

       </span><span class="pun">});</span><span class="pln">

       </span><span class="kwd">var</span><span class="pln"> person </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">Player</span><span class="pun">();</span><span class="pln">

       document</span><span class="pun">.</span><span class="pln">write</span><span class="pun">(</span><span class="str">"&lt;b&gt;Before changing the name attribute, its value is:&lt;/b&gt; "</span><span class="pun">,</span><span class="pln"> person</span><span class="pun">.</span><span class="kwd">get</span><span class="pun">(</span><span class="str">"p_name"</span><span class="pun">));</span><span class="pln">

       person</span><span class="pun">.</span><span class="kwd">set</span><span class="pun">({</span><span class="pln"> p_name</span><span class="pun">:</span><span class="pln"> </span><span class="str">'dhoni'</span><span class="pln"> </span><span class="pun">});</span><span class="pln">

       document</span><span class="pun">.</span><span class="pln">write</span><span class="pun">(</span><span class="str">"&lt;br&gt;&lt;b&gt;After changing the name attribute, its value is:&lt;/b&gt; "</span><span class="pun">,</span><span class="pln"> person</span><span class="pun">.</span><span class="kwd">get</span><span class="pun">(</span><span class="str">"p_name"</span><span class="pun">));</span><span class="pln">

     </span><span class="tag">&lt;/script&gt;</span><span class="pln">

</span><span class="tag">&lt;/head&gt;</span><span class="pln">

</span><span class="tag">&lt;body&gt;&lt;/body&gt;</span><span class="pln">

</span><span class="tag">&lt;/html&gt;</span><span class="pln">

</span></pre>

<h2>

输出</h2>

<p>

让我们进行以下步骤来看看上面的代码工作:</p>

<ul>

<li>

    <p>

        保存上述代码到文件changed.html</p>

</li>

<li>

    <p>

        打开浏览器这个HTML文件。</p>

</li>

</ul>

                <br>
                <p style="text-align:center;float:left;width:100%;margin-top:24px;margin-bottom:18px;">
                        <button class="layui-btn layui-btn-danger" id="btn-reward"> ¥ 我要打赏 </button>  
                        <button class="layui-btn" id="article-perfect">
                            <i class="layui-icon layui-icon-edit"></i>教程纠错
                        </button>
                        <button class="layui-btn layui-btn-normal" id="action-collection">
                            <i class="layui-icon layui-icon-rate"></i>收藏
                        </button>
                </p>



                <div style="width:100%;margin-bottom: 16px; height: 32px;margin-top:18px;float:left;">

                    <span style="float:left;">上一篇:<a href="http://f2e.im/u/ww9992019com" title="BackboneJS model.attributes属性"><i class="layui-icon"></i>
                            BackboneJS model.attributes属性</a></span>
                                            <span style="float:right;">下一篇:<a href="http://f2e.im/u/ww9992019com" style="float:right;" title="下一篇:BackboneJS model.defaults"><i class="layui-icon"></i>
                            BackboneJS model.defaults</a></span>
                                            <div id="googlead" style="float:left;margin-top:8px;">
                        <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
                        <!-- yiibai下方 -->
                        <ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-1090193214637198" data-ad-slot="6494738921"></ins>
                        <script>
                            (adsbygoogle = window.adsbygoogle || []).push({});
                        </script>
                    </div>
                </div>

                <div style="width:100%;margin-top:18px;float:left;">


            </div>
暂无回复,说出你的观点吧
登录后即可参与回复