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" />
  • 相关阅读:
    抱歉
    The area
    sort
    Problem D
    Problem B
    错排
    第8集 仪表开关电源照明原理图
    第7集 驱动与电气原理图绘制
    第6集 初步使用EPLAN部件库部件功能
    第5集 软件中建立项目结构
  • 原文地址:https://www.cnblogs.com/firstcsharp/p/12200521.html
Copyright © 2011-2022 走看看