在动态路由匹配和带参路由匹配页面增加closeTag关闭页面示例

This commit is contained in:
zhigang.li 2018-11-28 11:33:44 +08:00
parent 3ec36b6b8e
commit 42c153ff74
2 changed files with 40 additions and 2 deletions

View File

@ -2,13 +2,32 @@
<div> <div>
<Card> <Card>
<h2>ID: {{ $route.params.id }}</h2> <h2>ID: {{ $route.params.id }}</h2>
<Button @click="close">调用closeTag方法关闭本页</Button>
</Card> </Card>
</div> </div>
</template> </template>
<script> <script>
import { mapMutations } from 'vuex'
export default { export default {
name: 'argu_page' name: 'params',
methods: {
...mapMutations([
'closeTag'
]),
close () {
/**
* 如果是调用closeTag方法普通的页面传入的对象参数只需要写name字段即可
* 如果是动态路由和带参路由需要传入query或params字段用来区别关闭的是参数为多少的页面
*/
this.closeTag({
name: 'params',
params: {
id: this.$route.params.id
}
})
}
}
} }
</script> </script>

View File

@ -2,13 +2,32 @@
<div> <div>
<Card> <Card>
<h2>ID: {{ $route.query.id }}</h2> <h2>ID: {{ $route.query.id }}</h2>
<Button @click="close">调用closeTag方法关闭本页</Button>
</Card> </Card>
</div> </div>
</template> </template>
<script> <script>
import { mapMutations } from 'vuex'
export default { export default {
name: 'query' name: 'query',
methods: {
...mapMutations([
'closeTag'
]),
close () {
/**
* 如果是调用closeTag方法普通的页面传入的对象参数只需要写name字段即可
* 如果是动态路由和带参路由需要传入query或params字段用来区别关闭的是参数为多少的页面
*/
this.closeTag({
name: 'query',
query: {
id: this.$route.query.id
}
})
}
}
} }
</script> </script>