• 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>

  • 相关阅读:
    02 基本介绍
    01 概述 网络分层
    04 可扩展
    Java 注解2
    03 高可用
    重拾安卓_00_资源帖
    JavaUtil_09_通用工具类-01_Hutool
    java支付宝开发-01-沙箱环境接入
    java支付宝开发-00-资源帖
    svn_学习_01_TortoiseSVN使用教程
  • 原文地址:https://www.cnblogs.com/wfpanskxin/p/3551958.html
Copyright © 2020-2023  润新知