zoukankan      html  css  js  c++  java
  • Vue知识随笔

    全局参数

    1.global.js 先定义常量参数

    const BASE_URL = 'http://xxxx.xxxx.com/api';
    export default {
    	BASE_URL
    }
    

    2.main.js 在main.js里面创建全局参数

    import global from './../static/config/global';
    Vue.prototype.GLOBAL = global;
    

    3.vue页面内

    this.GLOBAL.BASE_URL
    

    $refs(vue $refs的基本用法)##

    <div id="app">
        <input type="text" ref="input1"/>
        <button @click="add">添加</button>
    </div>
    
    this.$refs.input1.value ="22"; //this.$refs.input1减少获取dom节点的消耗
    

    一般来讲,获取DOM元素,需document.querySelector(".input1")获取这个dom节点,然后在获取input1的值。
    但是用ref绑定之后,我们就不需要在获取dom节点了,直接在上面的input上绑定input1,然后$refs里面调用就行。
    然后在javascript里面这样调用:this.$refs.input1 这样就可以减少获取dom节点的消耗了

    获取路由内参数

    {
      path: '/proDetail/:id',
      name: 'ProDetail',
      component: ProDetail
    }
    
    this.productId = this.$route.params.id;
    

    获取链接中参数

    http://m.xxxx.com/#/latestPlan?chn=app
    
    this.$route.query.chn
  • 相关阅读:
    2019-11-12-WPF-添加窗口消息钩子方法
    2018-11-21-WPF-解决-ViewBox--不显示线的问题
    ARRAY_SIZE宏
    tcp校验和
    arp命令
    sk_buff
    printf打印字节
    dmesg命令
    insmod/rmmod
    ifup/ifdown
  • 原文地址:https://www.cnblogs.com/cuiyf/p/8042091.html
Copyright © 2011-2022 走看看