Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/418.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ssr nuxt页面转换的动态转换名称_Javascript_Vue.js - Fatal编程技术网

Javascript ssr nuxt页面转换的动态转换名称

Javascript ssr nuxt页面转换的动态转换名称,javascript,vue.js,Javascript,Vue.js,我正在尝试为nuxt页面转换使用一个动态转换名称,如下所示 导出默认值{ 数据(){ 返回{ 高度:0, transitionName:“页面” }; }, 过渡:{ 名称:this.transitionName, 离开前(el){ this.prevHeight=getComputedStyle(el).height; }, 输入(el){ const{height}=getComputedStyle(el); el.style.height=此高度; 设置超时(()=>{ el.style.

我正在尝试为nuxt页面转换使用一个动态转换名称,如下所示

导出默认值{
数据(){
返回{
高度:0,
transitionName:“页面”
};
},
过渡:{
名称:this.transitionName,
离开前(el){
this.prevHeight=getComputedStyle(el).height;
},
输入(el){
const{height}=getComputedStyle(el);
el.style.height=此高度;
设置超时(()=>{
el.style.height=高度;
}, 0);
},
后中心(el){
el.style.height='auto';
}
}
}
此代码将混合在所有页面组件中

但我这里有两个bug:

  • 无法读取未定义的属性“transitionName”
  • 重定向到其他页面时,
    prevHeight
    属性不会更改 我像这样加了一个水
    观察:{
    “高度”(高度){
    控制台日志(高度)
    }
    }
    
    控制台中不会打印任何内容
  • 还有什么: 我尝试通过使用回调函数而不是像这样的对象来修复它:

    transition(){
    返回{
    ...
    };
    }
    
    但这行不通

    我怎样才能做到这一点?我读书,但毫无帮助


    非常感谢

    读取nuxt的资源代码后,

    
    
    可以简单地认为

    <transition>
          <router-view/>
    </transition>
    
    就像一个水疗项目