-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.x version self layout no use,but the 0.x normal #1321
Comments
你的 SpecialLayout.vue 文件应该放入 .vuepress/theme/layouts 目录。 |
我找到原因了,跟1.x版本对比,是1.x版本移除了该功能 |
是个 issue,要优化 |
@leach-chen @ulivz 我这里 SpecialLayout.vue 貌似用的好好的啊(躺 |
另外,请把这个 issue 翻译成英文,谢谢。 |
In 0.x ,the default layout is undefined,but in 1.x,it changed to 'Layout'。if you haven't defined layout,it will be 'Layout'。we can change the Layout.vue like 0.x <div
class="custom-layout"
v-if="$page.frontmatter.layout !== 'Layout'"
>
<component :is="$page.frontmatter.layout"></component>
</div> 但是,每次路由被改变,layout 都会被重新赋值,即使是默认值,如果把 $page.frontmatter.layout 弄成计算属性,会造成堆栈溢出 |
如果像 @shigma 一样,放置在 layouts 目录,那么会替换掉整个页面,而不只是内容区域。 |
查看源码的逻辑是,如果定义的 layout 存在,那么就使用这个 [layout].vue 作为整个页面的布局。如果不存在,那么仍然会使用默认的 Layout.vue。 那么仍然可以像我前面所用的使用 $page.frontmatter.layout 在 Layout.vue 中进行判断。 也可以自定义一个 frontmatter,来进行判断使用哪个组件 |
已修改 |
不用
1.x可以在nodel_module下把主题拷出来重命名为themem放到.vuepress目录下,然后加回那段代码,官方既然说了是个issue,那就会改过来吧 |
@leach-chen 使用 |
现在只能用 |
Fixed at 0306574 and available at BTW, using components under components (i.e., global components) as layouts is really convenient, but in 1.x we still suggest you to place layout components at layout directory, which has better-defined duties. |
it seems use |
In 0.x, the layout system was implemented by the In 1.x, the layout system was implemented by the If you want to set global header, footer or sidebar, you should custom your globalLayout. BTW, you can create a feature request for default theme to open a new option of YAML front matter to support content-only layout. |
@ulivz ok |
Bug report
Version
1.x-alpha
Steps to reproduce
What is expected?
Custom Layout for Specific Pages
By default the content of each *.md file is rendered in a
layout: SpecialLayout
This will render .vuepress/components/SpecialLayout.vue for the given page.
Follow the official tutorial to use a custom layout in the md file
What is actually happening?
1.x version self layout no use,but the 0.x normal
Other relevant information
The text was updated successfully, but these errors were encountered: