Skip to content

docs(zh): update #2016

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

Merged
merged 13 commits into from
Aug 6, 2018
Merged

docs(zh): update #2016

merged 13 commits into from
Aug 6, 2018

Conversation

Jinjiang
Copy link
Member

@Jinjiang Jinjiang commented Aug 1, 2018

Translated all updates except ui-api.md which would be updated later with another pull request.
Ref: 09b72eb...686ec25
The diff is huge so I made a smaller one here: https://gist.github.com/Jinjiang/71758a20fa330528c81960c1eea10d05
Thanks
/ping @Justineo

@yyx990803 yyx990803 merged commit f9260cf into vuejs:dev Aug 6, 2018
@@ -104,11 +130,13 @@ module.exports = {

### lintOnSave

- Type: `boolean`
- Type: `boolean` | `error`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我感觉这里应该写成 `'error'`,否则会以为是个类型

@@ -234,6 +234,33 @@ export default {
<%# END_REPLACE %>
```

#### 文件名都极端情况
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文件名

@@ -2,13 +2,13 @@

## browserslist

你会发现 `package.json` 文件里有一个 `browserlist` 字段,指定里项目的目标浏览器的范围。这个值会被 [@babel/preset-env][babel-preset-env] 和 [Autoprefixer][autoprefixer] 用来确定需要转译的 JavaScript 特性和需要添加的 CSS 浏览器前缀。
你会发现有 `package.json` 文件里的 `browserlist` 字段 (或一个单独的 `.browserslistrc` 文件),指定了项目的目标浏览器的范围。这个值会被 [@babel/preset-env][babel-preset-env] 和 [Autoprefixer][autoprefixer] 用来确定需要转译的 JavaScript 特性和需要添加的 CSS 浏览器前缀。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉之前的翻译才对吧,会发现……里有一个……字段

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我怕引起歧义误认为之前的字段和括号里的是并列关系故意写成这样的,你觉得合适吗?或必要性大吗?

你会发现 package.json 文件里的 browserlist 字段 (或一个单独的 .browserslistrc 文件) 指定了项目的目标浏览器的范围

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

怕歧义的话我觉得也可以意译一下,比如:你可以使用 package.json 中的 browserlist 字段(也可以用一个单独的……)来……


```
vue-cli-service build --target wc --name my-element [entry]
```

这将会产生一个单独的 JavaScript 文件 (及其压缩后的版本) 将所有的东西都内联起来。当这个脚本被引入网页时,会注册自定义组件 `<my-element>`,其使用 `@vue/web-component-wrapper` 包裹了目标的 Vue 组件。这个包裹器会自动代理属性、特性、事件和插槽。请查阅 [`@vue/web-component-wrapper` 的文档](https://github.com/vuejs/vue-docs-zh-cn/blob/master/vue-web-component-wrapper/README.md)了解更多细节。
注意这里的入口应该是一个 `*.vue` 文件。Vue CLI 将会把这个组件自动包裹并注册为 Web Components 组件,无需在 `main.js` 里做这件事。你也完全可以在开发时以一个 demo app 使用 `main.js`。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

而无需在 main.js 中自行注册?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

也可以在开发时把 main.js 作为 demo app 单独使用

你可以通过 `vue ui` 命令使用 GUI 运行更多的特性脚本。
:::

这里有一个 GUI 的 Webpack Analyzer:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

webpack

@@ -25,6 +25,34 @@ $color = red;
</style>
```

### 自动化导入

如果你想自动化导入文件 (用于颜色、变量、mixin……),你可以使用 [style-resources-loader](https://github.com/yenshih/style-resources-loader)。这里有一个关于 stylus 的在每个单文件组件和 stylus 文件中导入 `./src/styles/imports.styl` 的例子:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stylus

@@ -74,6 +81,10 @@ console.log(process.env.VUE_APP_SECRET)

所有解析出来的环境变量都可以在 `public/index.html` 中以 [HTML 插值](./html-and-static-assets.md#插值)中介绍的方式使用。

::: tip 提示
你可以在 `vue.config.js` 文件中计算环境变量。它们仍然需要以 `VUE_APP_` 前缀开头。这可以用于版本信息 `process.env.VUE_APP_VERSION = require('./package.json').version`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最后缺句号

}
```

每个文件都需要暴露一个函数,将插件 API 作为第一个参数携带。关于插件 API 的更多信息可以查阅[插件开发指南](../dev-guide/plugin-dev.md)。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

接受插件 API 作为第一个参数

@Jinjiang Jinjiang deleted the zh branch August 6, 2018 03:22
@Jinjiang
Copy link
Member Author

Jinjiang commented Aug 6, 2018

@Justineo 你 review 的内容我会另外发一个 PR 👌

yyx990803 pushed a commit that referenced this pull request Aug 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants