1.获取地址栏参数 this.$route.query.id
2.用this.$router.push({path:'index',query:{id:1}})跳转页面无刷新,无法监听传递的参数,可用以下方法解决:
watch:{
'$route':'fun'
}
fun为地址栏变化要写的函数
3.组件变量是数组的,v-for时,要写:key="index";
4.在光标处插入值
<textarea ref="mytextarea" v-model='editMsg' class="editMsg" maxlength="333" ></textarea>
cursorInput(str){ //光标位置插入值
var tc = this.$refs.mytextarea;
var tclen = this.editMsg.length;
tc.focus();
if(typeof document.selection != "undefined"){
document.selection.createRange().text = str;
}else{
this.editMsg= this.editMsg.substr(0,tc.selectionStart)+str+this.editMsg.substring(tc.selectionStart,tclen);
}
},