zoukankan      html  css  js  c++  java
  • 在C#的MVC中 Vue的基本用法实例

    一、定义并实例化容器

     $(function () {
            var vueObj = new Vue({
                el: "#step-2",
                data: {
                    IsRequired:0,
                    PrepayMonths: 0,
                    MakeUpMonths: 0,
                    Title:'',
                    ExtraInfo: [],
                    SSCityType: [],
                    PFCityType:[]
                },
                watch: {
    
                }
            });
            initialPage();
        });

    二、给容器赋值

    AjaxJson("../../Sh/GetCityData?cityId=" + cityId, "get", null, function (data) {
        console.info(data);
        if (data.SSCityType.length != 0) {
            vueObj.IsRequired = data.IsRequired;
            vueObj.PrepayMonths = data.PrepayMonths;
            vueObj.MakeUpMonths = data.MakeUpMonths;
            vueObj.ExtraInfo = data.ExtraInfo;
            vueObj.SSCityType = data.SSCityType;
            vueObj.PFCityType = data.PFCityType;
            ……                
        }
    })

     三、各种使用方法

    1、动态style和input属性

    <div class="form-input">
     <label :style="{color:(IsRequired==1?'#ccc':'#000')}"><input type="radio" name="IsSS" id="IsSS" value="2" :disabled="IsRequired==1"></label>
    </div>

    2、循环使用及input动态属性是否选中

     <label v-for="(item,index) in SSCityType" :key="index">
       <input type="radio" name="InsuredTypeId" id="InsuredTypeId" :value="item.CityTypeId" :checked="index==0">{{item.Name}}                                    
    </label>

     3、实时监听输入框事件

    <input type="number" id="SSDIY" v-on:input="checkValue"/>

    checkValue是个js方法

     4、监听输入框失去焦点事件

    <input type="number" id="SSDIY" v-on:blur="checkValue" />
  • 相关阅读:
    P3688 [ZJOI2017] 树状数组 【二维线段树】
    CF516D Drazil and Morning Exercise【并查集,结论】
    Luogu5540 最小乘积生成树
    CDW数学小笔记
    ZROI 金华集训 线性代数选讲
    多项式乘法(代码)
    我的vimrc
    P4562 [JXOI2018]游戏
    [POJ3585]Accumulation Degree
    [CH5302]金字塔
  • 原文地址:https://www.cnblogs.com/firstcsharp/p/12200521.html
Copyright © 2011-2022 走看看