zoukankan      html  css  js  c++  java
  • vue数据绑定

    数据绑定

    <input type="tel" placeholder="请输入手机号" v-on:input="verifyPhone()" v-on:blur="verifyPhone()" v-model="phone" />
    <p class="labeltext">{{error_phone_msg}}</p>

    Js:

    data:{
        phone:"",                           //手机号
        error_phone_msg:"",                 //手机号错误提示
    },
    methods:{
        //验证手机号
        verifyPhone:function () {
            if (!Util.verifyPhone(this.phone)){
                vue_register.verify_phone_status = false;
                vue_register.error_phone_msg = "请输入正确的手机号";
            }else{
                $.ajax({
                    url:"http://*********************************** ",
                    type:"GET",
                    data:{phone:vue_register.phone},
                    dataType:"JSON",
                    success:function (data) {
                        if (data.data){
                            vue_register.verify_phone_status = false;
                            vue_register.error_phone_msg = "该手机号已被注册";
                        }else{
                            vue_register.verify_phone_status = true;
                            vue_register.error_phone_msg = null;
                        }
                    },
                    error:function (data) {
                        console.log("ajax请求错误:"+data)
                    }
                })
            }
        }

    总结:html向js传递数据用v-model

                         Js向html传递数据(1)先再data中声明

                                                              (2)html用{{messaage}}引用

  • 相关阅读:
    微服务-1初识
    RESTful-5开发API
    RESTful-4使用教程
    RESTful-3架构详解
    RESTful-2一分钟理解什么是REST和RESTful
    RESTful-1概述
    Swagger-概述
    net core体系-web应用程序-4asp.net core2.0 项目实战(任务管理系统)-2项目搭建
    net core体系-web应用程序-4asp.net core2.0 项目实战(任务管理系统)-1项目说明
    (大数 startsWith substring) Exponentiation hdu1063
  • 原文地址:https://www.cnblogs.com/wangyuyuan/p/6836193.html
Copyright © 2011-2022 走看看