欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Avalonjs双向数据绑定与监听的实例代码

程序员文章站 2022-11-19 21:11:35
废话不多说了,直接给大家贴代码了,具体代码如下所示:

废话不多说了,直接给大家贴代码了,具体代码如下所示:

<div class="content_table" ms-controller="checkname">
  <table>
    <thead>
      <tr>
        <th width="15%">提交核名</th>
        <th width="85%">请提供您打算使用的3个公司名称,我们将帮您注册并向登记机关提交您的核名信息。</th>
      </tr>
    </thead>
    <tbody >
      <tr>
        <td colspan="2">
          <p class="or">看我的公司名是否已被占用</p>
          <a class="refer">立即查询</a>
        </td>
      </tr>
      <tr>
      <td colspan="2">
        <p class="matter">
          <label>
            <span>行政区域:</span>
            <select name="" id="selarea" class="select_t" :duplex="@administrativeregions">
              <option value="天津市">天津市</option>
            </select>
          </label>
        </p>
        <form action="" id="c_name">
        <p class="matter">
          <label>
            <span>字号:</span>
            <input class="thing thing_nn" type="text" placeholder="云信" name='c_name' ms-duplex="@filedone"><br>
            <input class="thing thing_nn thing_add" type="text" name='s_name' placeholder="请输入第二个公司名称" ms-duplex="@filedtwo"><br>
            <input class="thing thing_nn thing_add" type="text" name='t_name' placeholder="请输入第三个公司名称" ms-duplex="@filedthree">
            <p class="err_tips"></p>
            <h4 style="font-weight: 300;width: 80%;margin: 0 0 20px 65px;"><em>提示:</em>1.企业名称=行政区域+字号+行业特点+公司类型,如北京云信科技有限公司,字号则为云信;2.字号由两个以上的汉字组成,不可输入外国文字、汉语拼音、阿拉伯数字;</h4>
          </label>
        </p>
        </form>
        <p class="matter">
          <label>
            <span>行业特点:</span>
            <select ms-duplex="@firstselected" class="select_t thing" id="trade_a">
              <option ms-for="el in @first" ms-attr="{value:el}" >{{el}}</option>
            </select>
            <select class="select_t thing" id="trade_b" :duplex="@secondselected">
              <option ms-for="el in @second" ms-attr="{value:el}" >{{el}}</option>
            </select>
          </label>
        </p>
        <p class="matter">
          <label>
            <span>公司类型:</span>
            <a style="display: inline-block;">{{@typeofcompany}}</a>
          </label>
        </p>
        <div class="text_t">根据您输入的信息生成的名称如下(请选择您中意的3个名称):</div>
        <div class="three_select">
          <label><input type="checkbox" name="apk[]" value="1">{{@administrativeregions + @filedone + @secondselected + @typeofcompany}}</label>
          <label><input type="checkbox" name="apk[]" value="2">{{@filedone }} ({{@administrativeregions}}) {{@secondselected + @typeofcompany}}</label>
          <label><input type="checkbox" name="apk[]" value="3">{{@filedone + @secondselected }} ({{@administrativeregions}}) {{@typeofcompany}}</label>
          <!--<label><input type="checkbox" name="apk[]" value="10">{{@administrativeregions + @filedone + @secondselected + @typeofcompany}}</label>
          <label><input type="checkbox" name="apk[]" value="11">{{@filedone }} ({{@administrativeregions}}) {{@secondselected + @typeofcompany}}</label>
          <label><input type="checkbox" name="apk[]" value="12">{{@filedone + @secondselected }} ({{@administrativeregions}}) {{@typeofcompany}}</label>-->
          <div class="my_comp_f">
            <label><input type="checkbox" name="apk[]" value="4">{{@administrativeregions + @filedtwo + @secondselected + @typeofcompany}}</label>
            <label><input type="checkbox" name="apk[]" value="5">{{@filedtwo}} ({{@administrativeregions}}) {{@secondselected + @typeofcompany}}</label>
            <label><input type="checkbox" name="apk[]" value="6">{{@filedtwo + @secondselected}} ({{@administrativeregions}}) {{@typeofcompany}}</label>
          </div>
          <div class="my_comp_t">
            <label><input type="checkbox" name="apk[]" value="7">{{@administrativeregions + @filedthree + @secondselected + @typeofcompany}}</label>
            <label><input type="checkbox" name="apk[]" value="8">{{@filedthree}} ({{@administrativeregions}}) {{@secondselected + @typeofcompany}}</label>
            <label><input type="checkbox" name="apk[]" value="9">{{@filedthree + @secondselected}} ({{@administrativeregions}}) {{@typeofcompany}}</label>
          </div>
        </div>
        <div class="table_button">
          <!--<a class="next_step" href="submit_name_perfect.html" rel="external nofollow" >下一步,完善核名信息</a>-->
          <a class="next_step" href="javascript:void(0);" rel="external nofollow" >下一步,完善核名信息</a>
        </div>
      </td>
    </tr>
    </tbody>
  </table>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/avalon.js/2.2.4/avalon.min.js"></script>
$(document).ready(function(){
  var citys=$('#selarea').val();
if(citys == "天津市"){
  $('.refer').attr("href","http://zzsb.tjmqa.gov.cn/selfreport/nameregister/gomain");
  $('#selarea').append('<option>天津</option><option>天津滨海新区</option><option>天津市滨海新区</option>');
}else if(citys == "绵阳市"){
  $('#selarea').append('<option>绵阳</option><option>绵阳高新区</option>');
}
});
var map = {
  "科技类": ['请选择','科技','教育科技','科技发展','生物科技','电子科技','环保科技','网络科技','生化科技','激光科技','节能科技','能源科技','农业科技','医药科技等'],
  "技术类": ['请选择','技术','环境技术','农业高新技术','检测技术','信息技术','经济技术','消防技术','工程技术','机电技术','生物技术','新能源技术'],
  "文化类": ['请选择','文化','文化发展','文化传播','文化传媒','文化交流'],
  "咨询类": ['请选择','咨询','信息咨询','教育咨询','投资咨询','管理咨询','建筑设计咨询','文化信息咨询'],
  "培训类": ['请选择','培训','技术培训','企业管理培训','计算机技术培训'],
  "设计类": ['请选择','设计','建筑设计','家居装饰设计','旅游规划设计'],
  "服务类": ['请选择','服务','劳务服务','会议服务','家政服务','商务服务','婚庆服务'],
  "广告类": ['请选择','广告','广告传媒'],
  "商贸类": ['请选择','商贸','贸易','服装装饰','针纺织品','装饰品'],
  "贸易类": ['请选择','进出口贸易'],
  "租赁类": ['请选择','建筑机械设备租赁','骑车租赁'],
  "工程类": ['请选择','工程','建筑工程','装饰工程','园林绿化工程','照明工程','通讯工程'],
  "物流类": ['请选择','物流','物流运输'],
  "管理类": ['请选择','管理','投资管理','企业管理','餐饮管理','管理顾问','金融管理'],
  "维修类": ['请选择','维修','电器维修','机械维修'],
  "机械设备类": ['请选择','机械设备','办公设备','消防设备','自控设备','机电设备','冷暖设备','环保设备','测试设备','电力设备','实验室设备'],
  "印刷类": ['请选择','印刷','印刷设计','印刷技术','印刷器材'],
  "医疗器械": ['请选择','医疗器械'],
  "养殖": ['请选择','养殖'],
  "房地产经纪": ['请选择','房地产经纪']
};
var vm = avalon.define({
  $id: 'checkname',
  administrativeregions: '天津',
  filedone: '云信',
  filedtwo: '',
  filedthree:'',
  features:'科技',
  typeofcompany:'有限公司',
  first: ["科技类", "技术类", "文化类","咨询类","培训类","设计类","服务类","广告类","商贸类","贸易类","租赁类","工程类","物流类","管理类","维修类","机械设备类","印刷类","医疗器械","养殖","房地产经纪"],
  second: map['科技类'].concat(),
  firstselected: "科技类",
  secondselected: "请选择",
});
vm.$watch("firstselected", function (a) {
  vm.second = map[a].concat()
  vm.secondselected = vm.second[0] 
});
vm.$watch("filedtwo", function (a) {$('.my_comp_f').show()});
vm.$watch("filedthree", function (a) {$('.my_comp_t').show()});

以上所述是小编给大家介绍的avalonjs双向数据绑定与监听的实例代码,希望对大家有所帮助