vue 知识点

仅为自己学习的记录。


本地存储

括号value存到key中

sessionStorage.setItem('uname', req.content.userName)

vue 页面加载时取值

created () {
    this.username = sessionStorage.getItem('uname')
  }

移除本地缓存

sessionStorage.removeItem('uname')

input取值

<!-- html -->
<input type="text" ref="sum" placeholder="请输入">
// js
var orderAmount = that.$refs.sum.value
console.log(orderAmount)


多个拼到一起

<!-- html -->
<input type="text" ref="keyWord1" class="keyinput">
<input type="text" ref="keyWord2" class="keyinput">
<input type="text" ref="keyWord3" class="keyinput">


// js
export default {
  data () {
    return { 
      keywords: []
 } }}
that.keywords.push(that.$refs.keyWord1.value)
that.keywords.push(that.$refs.keyWord2.value)
that.keywords.push(that.$refs.keyWord3.value)var keyword = that.keywords + ','


checkbox取值


<!-- html -->
<input type="checkbox" v-model="statistics" value='请输入'>
// js
export default {
  data () {
    return {
      statistics: []
    }
  }
}
var statistics = that.statistics + ','

跳转页面(前提 写好路由路径)

this.$router.push('/login')
// 刷新页面
window.location.reload()

跳转页面时传值

// 传值(path是跳转路径,orderId是随便取的名,e是所传的值)
this.$router.push({path: 'orderinfo', query: { orderId: e }})
// 取值
var orderId = {orderId: this.$route.query.orderId}


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

猜你喜欢

转载自blog.csdn.net/Feel__/article/details/78052140