• knockoutjs关键点


    <p>Your value: <input data-bind="value: someValue, valueUpdate: 'afterkeydown'"/></p>
    <p>You have typed: <span data-bind="text: someValue"></span></p>
    someValue: ko.observable("edit me")

    部分实例:

    <div data-bind="html:details"></div>
    <div data-bind="css: { profitWarning: currentProfit() < 0 }">100万 </div>
    <div data-bind="style: { color: currentProfit() < 0 ? 'red' : 'black' }">
    <a data-bind="attr: { href: url, title: details2 }"> Report</a>
    Profit Information
    </div>
    You've clicked <span data-bind="text: numberOfClicks"></span> times
    <button data-bind="click: incrementClickCounter">Click me</button>
    <div>
    <div data-bind="event: { mouseover: enableDetails, mouseout: disableDetails }"> Mouse over me </div>
    <div data-bind="visible: detailsEnabled"> Details </div>
    </div>
    <input data-bind="value: someModelProperty" />
    <p> <input type='checkbox' data-bind="checked: hasCellphone"/> I have a cellphone</p>
    <p> Your cellphone number: <input type='text' data-bind="value: cellphoneNumber, enable: hasCellphone"/></p>
    <p>Your value: <input data-bind="value: someValue, valueUpdate: 'afterkeydown'"/></p>
    <p>You have typed: <span data-bind="text: someValue"></span></p>

    <script type="text/javascript" src="jquery-1.9.1.js"></script>
    <script type="text/javascript" src="knockout-v2.2.1.js"></script>


    <script type="text/javascript">

    var myviewModel = {
    details: ko.observable(),
    currentProfit: ko.observable(150000),
    url: ko.observable("year-end.html"),
    details2: ko.observable("Report including final year-end statistics"),
    numberOfClicks: ko.observable(0),
    incrementClickCounter: function () {
    var previousCount = this.numberOfClicks();
    this.numberOfClicks(previousCount + 1);
    },
    detailsEnabled: ko.observable(false),
    enableDetails: function () {
    this.detailsEnabled(true);
    },
    disableDetails: function () {
    this.detailsEnabled(false);
    },
    someModelProperty:ko.observable(""),
    hasCellphone: ko.observable(false),
    cellphoneNumber: ko.observable(""),
    someValue: ko.observable("edit me")

    };
    ko.applyBindings(myviewModel);
    myviewModel.details("<em>For further details, view the report <a href='report.html'>here</a>.</em>");
    myviewModel.currentProfit(-50);

    </script>

  • 相关阅读:
    SPOJ 4487. Can you answer these queries VI splay
    Oracle Enterprise Linux 64-bit 下Oracle11g的监听配置改动及測试步骤
    欧拉函数
    安装Windows7步骤
    在Eclipse中执行、配置Hadoop
    java设计模式演示样例
    VC中获取窗体句柄的各种方法
    HTML5 Canvas中实现绘制一个像素宽的细线
    Java实现 蓝桥杯VIP 基础练习 Sine之舞
    Java实现 蓝桥杯VIP 基础练习 Sine之舞
  • 原文地址:https://www.cnblogs.com/wfpanskxin/p/3551958.html
Copyright © 2020-2023  润新知