Comments (6)
nuxt.js 中 layout 不仅仅是一个字符串,而是对应的 layouts 里的模板,你没有对应的模板,则必然找不到了。
- 如果使用 nuxt.js 的 layout 则需要模板,不必维护所谓的“变量”
- 若不使用,则可以在根组件自行根据“变量”来渲染元素
from surmon.me.
我有对应的模板,vertical及horizontal这两个模板都可以正确使用,如果我单个这样写layout : 'vertical'或者layout : 'horizontal'都是能渲染出来的。但现在需求是要通过页面的一个按钮来动态切换这两种布局,所以我的做法是通过切换layout的值来做到,但现在获取了值后赋给layout时总说这个值未定义,但我在computed里是能获取到的
from surmon.me.
你可以这样测试,测试一个猜想:在 layout 被读取并应用之前,computed 是还没有被实例化的。
把
layout : 'horizontal'
更换为
layout : (function() { console.log(this); return 'horizontal' }())
如若成立,则“将layout保存在 store ”这条路是行不通的。
from surmon.me.
我刚试过了,layout : (function() { console.log(this); return 'horizontal' }())这样写输出了undefined,页面是按horizontal渲染出来了。但是如果不把layout保存在store里面怎么做到其它所有页面都可以取到值?大神有其它思路来实现这个需求的么?
from surmon.me.
换个说法:“layout 不支持动态变更”。所以用自定义“layout”来实现吧,像我一样。
from surmon.me.
嗯,正在研究您的代码,非常感谢您的指点
from surmon.me.
Related Issues (20)
- vuniversal 分支是不可以build吗 看yarn build 没有vuniversal文件夹下的build HOT 2
- 哔哩哔哩那块的视频封面的nginx反向代理该如何配置 HOT 3
- prod 环境主体样式没丢失 HOT 2
- 启动后出现的语法报错 HOT 2
- ssr运行错误 HOT 5
- [NEED UPDATE] update your blog posts HOT 4
- Cannot find module ... 🤷♀️
- Cannot find module ... 🤷♀️
- 也是ssr运行错误,但与上一个提问的报错信息不同 HOT 3
- yarn build||yarn build:ssr 报错 HOT 3
- 请问作者,之前网站是用nuxt构建的,为什么换掉了?是因为nuxt有什么解决不了的缺陷么?还是有其他原因? HOT 2
- 求教一下,如何在nuxt里面进行ABTest HOT 2
- 发布一个很水的问题给作者大大 HOT 7
- 有个疑问
- [求助]: 我想请问下源码中`renderSripts`部分的作用 HOT 3
- 请问下这个可以商用么?
- 为什么管理后台和前端用的不同的技术栈? HOT 2
- run dev error HOT 2
- pnpm run dev无法启动 win10 系统 HOT 1
- 项目启动报错的问题 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from surmon.me.