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
  • 相关阅读:
    设计模式之单例模式
    设计模式之原型模式
    设计模式之建造者模式
    设计模式之抽象方法模式
    设计模式之简单工厂模式
    java中内存分配
    java引用类型
    Oracle
    Oracle
    Oracle
  • 原文地址:https://www.cnblogs.com/cuiyf/p/8042091.html
Copyright © 2011-2022 走看看