【发布时间】:2022-11-29 02:39:26
【问题描述】:
我有一个页面,如果用户来自某个 URL,我想在其中显示一条消息:
如果来自此 URL:
http://www.testapp.com?_a=lookingforthis&token=5b6b7f/account/about
<template>Show this message</template>
如果从这里: http://www.testapp.com/account/about
<template>Dont show this message</template>
我需要在 mounted() 或 method() 中执行此操作吗?
这是触发它的正确方法吗?
this.$route.query?.lookingforthis
【问题讨论】:
-
computed()听起来不错。或者将条件内联到模板中。 -
@kissu 谢谢你。请问this.$route.query?.lookingforthis在这个例子中是否有效?
-
http://www.testapp.com?_a=lookingforthis&token=5b6b7f/account/about不是真的有效。特别是这里查询的是_a,而且路径在查询之后,应该是相反的。
标签: javascript vuejs2