-
Notifications
You must be signed in to change notification settings - Fork 3.4k
translated components-slots.md #705
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
Conversation
src/v2/guide/components-slots.md
Outdated
@@ -29,47 +29,47 @@ Then in the template for `<navigation-link>`, you might have: | |||
</a> | |||
``` | |||
|
|||
When the component renders, the `<slot>` element will be replaced by "Your Profile". Slots can contain any template code, including HTML: | |||
当组件渲染的时候,这个 `<slot>` 元素将会替换掉“Your Profile”。插槽内可以包含任何代码,包括 HTML: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
将会被替换为“Your Profile”
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
任何模板代码
src/v2/guide/components-slots.md
Outdated
|
||
## Named Slots | ||
## 具名的插槽 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
具名插槽?这个算一个术语吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以
src/v2/guide/components-slots.md
Outdated
@@ -115,7 +115,7 @@ Or, the `slot` attribute can also be used directly on a normal element: | |||
</base-layout> | |||
``` | |||
|
|||
There can still be one unnamed slot, which is the **default slot** that serves as a catch-all outlet for any unmatched content. In both examples above, the rendered HTML would be: | |||
我们还是可以保留一个没有命名插槽,这个插槽是**默认插槽**,也就是说它作为一个抓住全部的出口承载了所有没有命名的内容。上述两个示例渲染出来的 HTML 都将会是: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
未命名插槽?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
它会作为所有未匹配到插槽的内容的统一出口?
src/v2/guide/components-slots.md
Outdated
|
||
There are cases when it's useful to provide a slot with default content. For example, a `<submit-button>` component might want the content of the button to be "Submit" by default, but also allow users to override with "Save", "Upload", or anything else. | ||
有的时候为插槽提供默认的内容是很有用的。例如,一个 `<submit-button>` 组件可能希望这个按钮的默认内容是“Submit”,但是同时允许用户覆写为“Save”、“Upload”或别的内容。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(题外话,我发现这里用的话术完全是「default」而不是「fallback」……)
src/v2/guide/components-slots.md
Outdated
|
||
## Scoped Slots | ||
## 带作用域的插槽 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我在想这个地方是不是都统一写成「默认插槽」、「具名插槽」、「作用域插槽」这样偏术语的写法?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我觉得可以
src/v2/guide/components-slots.md
Outdated
|
||
### Destructuring `slot-scope` | ||
### 解构 `slot-scope` | ||
|
||
The value of `slot-scope` can actually accept any valid JavaScript expression that can appear in the argument position of a function definition. This means in supported environments ([single-file components](single-file-components.html) or [modern browsers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Browser_compatibility)) you can also use [ES2015 destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Object_destructuring) in the expression, like so: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删
src/v2/guide/components-slots.md
Outdated
|
||
The value of `slot-scope` can actually accept any valid JavaScript expression that can appear in the argument position of a function definition. This means in supported environments ([single-file components](single-file-components.html) or [modern browsers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Browser_compatibility)) you can also use [ES2015 destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Object_destructuring) in the expression, like so: | ||
如果一个 JavaScript 表达式在一个函数定义的参数位置有效,那么这个表达式实际上就可以被 `slot-scope` 接受。也就是说你可以在这些被支持的环境下 ([单文件组件](single-file-components.html)或[现代浏览器](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#浏览器兼容)),在这些表达式中使用 [ES2015 解构语法](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#解构对象)。例如: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在这些被支持的环境下 → 在支持的环境下
可以参考第二次提交作为中英文的 diff
谢谢