zoukankan      html  css  js  c++  java
  • vue基础笔记总结

    1.click.stop阻止点击事件继续传播

    <button @click.stop="dothis">阻止单击事件继续传播</button>

    2.@input监听input输入事件

    <input
    :type="type"
    :value="value"
    :placeholder="placeholder"
    :name="name"
    @input="$emit('input',$event.target.value)"
    />

    3.$event.target.value获取当前文本框的值

    <input :value=var @input="$emit('updata:val',$event.target.value)"

    4.在git上添加自己的名称,邮箱

    $ git config -- global user.name "sudongxue"

    修改邮箱

    $ git config -global user.email "邮箱地址"

    刚添加的分支更新在编辑器上找不到时 git指令更新

    git fetch

    5.vue根据class名隐藏多个div

    this.$('.div1, .div2').css('visibility','hidden')

    6.i%5=0    %取余

    只有当i为5的倍数的时候值为1,其他数为0

    在if语句中1为真,0为假

    if(i%5==0&&i%3)

    i是5的倍数,但不是3的倍数。

    7.js中的运算符

    +加 -减 *乘 /除 %求余数(保留整数) ++累加  --递减

    8.js中的逻辑运算符

    && || !

    9.条件运算符(三目运算)

    表达式A?表达式B:表达式C

    若A为真(非0)则将B的值作为整个表达式的取值,否则(A为0)将C作为取值

    Eg:max=(a>b)?a:b     (a>b)为true max=a否则max=b 将a和b两者较大值赋给max

      min=(a<b)!a:b   将a和b两者较小值赋给min

    10.vue获取当前点击div的html值

    <div @click="btn_user($event)">用户</div>

      methods:{

      btn_user(e){

      console.log(e.target.innerHTML)

    }

    }

    11.刚加载页面时,直接调用某个方法

    mounted:function(){

      this.a()

    },

    methods:{

    a(){

      console.log(123)

    }

    12.vue中的渲染函数render,h是元素,params是数据,params.row.当前这一条数据

    render:(h,params)=>{

    If(this.tableData[params.index].cover){

    return h(‘div‘,{

    attrs:{

    class:’domeClass’

    }

    },[h(“img”,{

    Attrs:{

    Src:this.tableData[params.index].imgSrc

    }

    })])

    }

    }else{

    Return h

    }

    13.转换为字符串

    let str_data=JSON.stringify(data);

    14.获取元素

    this.$('.className')

    15.从数据库获取的图片数据显示到页面上

    render:(h,params)=>{

      return h('img',{

        attrs:{

          class:'sampleImg',

          src:'/file/download'+this.listData[params.index].imgUrl

        }

      })

    }

    16.dataType是ajax数据返回类型

    data(){

    Brandid:brandId==”qy”?1:2

    (brandId的值如果是qy就赋值为1否则就为2)

    }

    17.Content-Type 指定不同格式的请求信息

    $.ajax({
    type: 'get',
    url: '/sampleStock/confirmInfo',
    headers: {
    'Content-Type': 'application/json;charset=UTF-8'
    },
    data: {
    sampleDressIdList: action
    },
    success: function (data) {
    },
    error: function (textStatus, errorThrown) {
    }
    });

    18.vue返回上级路由

    this.$router.back(-1)

    19.vue跳转页面,并传值,获取值

    //接收路由传来的值

    let name = this.$route.query.name
    //跳转路由并传值
    this.$router.push('/add?id=' + this.id)  
    //根据路由name
    this.$router.push({name:'routerName',query:{id:this.id}})
    //根据路由跳转地址
    this.$router.push({path:'/list',query:{id:this.id}})
    返回前一页 this.$router.back(-1)
    this.$router.go(val) => 在history记录中前进或者后退val步,当val为0时刷新当前页面。
    this.$router.push(path) => 在history栈中添加一条新的记录。
    21.本地缓存数组对象要先转换为字符串才能存储;然后再转换为数组对象使用
    //存储
    localStorage.tableData =JSON.stringify(ArrayObject) 
    //获取
    let tableData = JSON.parse( localStorage.tableData)
  • 相关阅读:
    t
    溢出
    https://stackoverflow.com/questions/45591594/fetch-does-not-send-headers
    显示在用户屏幕上的缩略图
    cache buffer
    LZW
    t
    指针悬挂
    使用Linux服务器来通过网络安装和激活Windows 7 —— 一些基本原理
    在C++中如何动态分配一个二维数组
  • 原文地址:https://www.cnblogs.com/wssdx/p/10758073.html
Copyright © 2011-2022 走看看