Commit 7ab0b4d3 authored by Jinjiang's avatar Jinjiang

[docs][zh] translated functional.md

parent db78dbe3
# Functional Components
# 函数式组件
Functional components defined as a Single-File Component in a `*.vue` file also receives proper template compilation, Scoped CSS and hot-reloading support.
在一个 `*.vue` 文件中以单文件形式定义的函数式组件,现在在模板编译、有作用域的 CSS 和热重载也有了良好的支持。
To denote a template that should be compiled as a functional component, add the `functional` attribute to the template block. This also allows omitting the `functional` option in the `<script>` block.
要声明一个应该编译为函数式组件的模板,请将 `functional` 特性添加到模板块中。这样做以后就可以省略 `<script>` 块中的 `functional` 选项。
Expressions in the template are evaluated in the [functional render context](https://vuejs.org/v2/guide/render-function.html#Functional-Components). This means props need to be accessed as `props.xxx` in the template:
模板中的表达式会在[函数式渲染上下文](https://cn.vuejs.org/v2/guide/render-function.html#函数式组件)中求值。这意味着在模板中,prop 需要以 `props.xxx` 的形式访问:
``` vue
<template functional>
......@@ -12,7 +12,7 @@ Expressions in the template are evaluated in the [functional render context](htt
</template>
```
If you need to access properties defined globally on `Vue.prototype`, you can access them on `parent`:
你可以在 `parent` 上访问 `Vue.prototype` 全局定义的属性:
``` vue
<template functional>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment