1.点击事件冒泡穿透问题:
@click.stop与@click.prevent
@click.stop 阻止事件冒泡
@click.prevent 阻止事件的默认行为,
<a href="http://www.baidu.com" @click.prevent="test4">百度一下</a> //阻止a标签跳转,仅执行函数test4
<form action="/xxx" @submit.prevent="test5"> //阻止表单提交,仅执行函数test5
<input type="submit" value="注册">
</form>
2.uniapp在页面跳转时,若URL太长的字符串会导致数据传递失败
url有长度限制,太长的字符串会传递失败,可使用窗体通信、全局变量,或encodeURIComponent
等多种方式解决,如下为encodeURIComponent
示例的解决方法。
<navigator :url="'/pages/test/test?item='+ encodeURIComponent(JSON.stringify(item))"></navigator>
// 在下一个.vue页面接受参数 onLoad: function (option) { let item = JSON.parse(decodeURIComponent(option.item)); }
3.子父组件传递参数:https://www.cnblogs.com/Alex-Song/p/12156989.html