12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <template>
- <div id="app">
- <!-- App页作为公共组件 -->
- <!-- 我们可以使用router-view组件来实现点击导航不刷新页面的效果,只在当前页面打开内容 -->
- <router-view v-if="isRouterAlive"></router-view>
- </div>
- </template>
- <script>
- export default {
- provide(){
- return{
- reload:this.reload
- }
- },
- data(){
- return{
- isRouterAlive:true
- }
- },
- methods:{
- reload(){
- this.isRouterAlive=false;
- this.$nextTick(function(){
- this.isRouterAlive=true
- })
- }
- }
- }
- </script>
- <style>
- *{
- /* 当style标签具有该scoped属性时,其CSS将仅应用于当前组件的元素 */
- /* 当前页面没有用scoped属性,因为App页面作为我们公共组件*/
- margin: 0px;
- padding: 0px;
- }
- #app{
- height: 100%;
- }
- </style>
|