vue简单操作

首先页面单独引用vue.js

<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

HTML:

<div id="app"> {{ message }} </div>

需要vue渲染的页面,在最外层设置ID

JS:

var app = new Vue({ el: '#app', data: { message: 'Hello Vue!' } })

常用的方法:

v-model 绑定

v-if、v-else-if、v-else判断

v-for循环

v-bind指令

v-model监听数据以及指令,数据双向绑定

@input 一般用于监听事件

 只要输入的值变化了就会触发input

@click事件

<div @click='dianji'></div>

this.$router.push("/index") 跳转路径

调用接口:

axios({
  withCredentials: true,
  method: 'post',
  url: this.H5url+'/service/Login/testLogin',
  data:{
    "player_id":_this.inputLs,
  }
})
.then(function(response) {//成功

})
.catch(function (error) {//失败
  console.log(error)
})

行内数据判断:

例:

{{scope.row.headimgurl == 0?'會員':'管理員'}}

v-show 类似display

例:v-show=“status == 1”  的时候这一块显示

原文地址:https://www.cnblogs.com/PoisonousMushrooms/p/12196628.html