Skip to content

Commit

Permalink
Fix some text and links to the old domain
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinjiang committed Jan 14, 2023
1 parent c06af93 commit 80a0d58
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "cn.vuejs.org",
"name": "v2.cn.vuejs.org",
"private": true,
"hexo": {
"version": "6.2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/v2/cookbook/creating-custom-scroll-directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ order: 7

## 基本的示例

我们可能很多次想为网站的滚动事件添加一些行为,尤其是动画。已有的做法很多,但是代码和依赖最少的方式可能就是使用一个[自定义指令](../guide/custom-directive.html)创建一个钩子,在特定的滚动事件之后作处理。
我们可能很多次想为网站的滚动事件添加一些行为,尤其是动画。已有的做法很多,但是代码和依赖最少的方式可能就是使用一个[自定义指令](/v2/guide/custom-directive.html)创建一个钩子,在特定的滚动事件之后作处理。

```js
Vue.directive('scroll', {
Expand Down
2 changes: 1 addition & 1 deletion src/v2/cookbook/packaging-sfc-for-npm.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Vue already allows components to be written as a single file. Because a Single F

> "Why can't people use my `.vue` file directly? Isn't that the simplest way to share components?"
It's true, you can share `.vue` files directly, and anyone using a [Vue build](https://vuejs.org/v2/guide/installation.html#Explanation-of-Different-Builds) containing the Vue compiler can consume it immediately. Also, the SSR build uses string concatenation as an optimization, so the `.vue` file might be preferred in this scenario (see [Packaging Components for npm > SSR Usage](#SSR-Usage) for details). However, this excludes anyone who wishes to use the component directly in a browser via `<script>` tag, anyone who uses a runtime-only build, or build processes which don't understand what to do with `.vue` files.
It's true, you can share `.vue` files directly, and anyone using a [Vue build](/v2/guide/installation.html#Explanation-of-Different-Builds) containing the Vue compiler can consume it immediately. Also, the SSR build uses string concatenation as an optimization, so the `.vue` file might be preferred in this scenario (see [Packaging Components for npm > SSR Usage](#SSR-Usage) for details). However, this excludes anyone who wishes to use the component directly in a browser via `<script>` tag, anyone who uses a runtime-only build, or build processes which don't understand what to do with `.vue` files.

Properly packaging your SFC for distribution via npm enables your component to be shared in a way which is ready to use everywhere!

Expand Down
4 changes: 2 additions & 2 deletions src/v2/cookbook/practical-use-of-scoped-slots.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ So far, so good. With all that done, we could continue adding the other objects

But, we want to use our `GoogleMapLoader` component only as a loader that prepares the map — we don’t want to render anything on it.

To achieve that, we need to allow the parent component that will use our `GoogleMapLoader` to access `this.google` and `this.map` that are set inside the `GoogleMapLoader` component. That’s where [scoped slots](https://v2.vuejs.org/v2/guide/components-slots.html#Scoped-Slots) really shine. Scoped slots allow us to expose the properties set in a child component to the parent component. It may sound like Inception, but bear with me one more minute as we break that down further.
To achieve that, we need to allow the parent component that will use our `GoogleMapLoader` to access `this.google` and `this.map` that are set inside the `GoogleMapLoader` component. That’s where [scoped slots](/v2/guide/components-slots.html#Scoped-Slots) really shine. Scoped slots allow us to expose the properties set in a child component to the parent component. It may sound like Inception, but bear with me one more minute as we break that down further.

### 2. Create component that uses our initializer component.

Expand Down Expand Up @@ -206,7 +206,7 @@ Now, when we have the slot in the child component, we need to receive and consum

### 4. Receive exposed props in the parent component using `slot-scope` attribute.

To receive the props in the parent component, we declare a template element and use the `slot-scope` attribute. This attribute has access to the object carrying all the props exposed from the child component. We can grab the whole object or we can [de-structure that object](https://v2.vuejs.org/guide/components-slots.html#Destructuring-slot-scope) and only what we need.
To receive the props in the parent component, we declare a template element and use the `slot-scope` attribute. This attribute has access to the object carrying all the props exposed from the child component. We can grab the whole object or we can [de-structure that object](/v2/guide/components-slots.html#Destructuring-slot-scope) and only what we need.

Let’s de-structure this thing to get what we need.

Expand Down
4 changes: 2 additions & 2 deletions src/v2/examples/vue-20-todomvc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ <h1>todos</h1>
},

// computed properties
// http://vuejs.org/guide/computed.html
// http://v2.vuejs.org/guide/computed.html
computed: {
filteredTodos: function() {
return filters[this.visibility](this.todos);
Expand Down Expand Up @@ -227,7 +227,7 @@ <h1>todos</h1>

// a custom directive to wait for the DOM to be updated
// before focusing on the input field.
// http://vuejs.org/guide/custom-directive.html
// http://v2.vuejs.org/guide/custom-directive.html
directives: {
"todo-focus": function(el, binding) {
if (binding.value) {
Expand Down
6 changes: 3 additions & 3 deletions src/v2/guide/components-edge-cases.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ inject: ['getMap']

<p class="tip">然而,依赖注入还是有负面影响的。它将你应用程序中的组件与它们当前的组织方式耦合起来,使重构变得更加困难。同时所提供的 property 是非响应式的。这是出于设计的考虑,因为使用它们来创建一个中心化规模化的数据跟<a href="#访问根实例">使用 <code>$root</code></a>做这件事都是不够好的。如果你想要共享的这个 property 是你的应用特有的,而不是通用化的,或者如果你想在祖先组件中更新所提供的数据,那么这意味着你可能需要换用一个像 <a href="https://github.com/vuejs/vuex">Vuex</a> 这样真正的状态管理方案了。</p>

你可以在 [API 参考文档](https://v2.cn.vuejs.org/v2/api/#provide-inject)学习更多关于依赖注入的知识。
你可以在 [API 参考文档](/v2/api/#provide-inject)学习更多关于依赖注入的知识。

## 程序化的事件侦听器

Expand Down Expand Up @@ -235,7 +235,7 @@ methods: {

查阅[这个示例](https://codesandbox.io/s/github/vuejs/v2.vuejs.org/tree/master/src/v2/examples/vue-20-programmatic-event-listeners)可以了解到完整的代码。注意,即便如此,如果你发现自己不得不在单个组件里做很多建立和清理的工作,最好的方式通常还是创建更多的模块化组件。在这个例子中,我们推荐创建一个可复用的 `<input-datepicker>` 组件。

想了解更多程序化侦听器的内容,请查阅[实例方法 / 事件](https://v2.cn.vuejs.org/v2/api/#实例方法-事件)相关的 API。
想了解更多程序化侦听器的内容,请查阅[实例方法 / 事件](/v2/api/#实例方法-事件)相关的 API。

<p class="tip">注意 Vue 的事件系统不同于浏览器的 <a href="https://developer.mozilla.org/zh-CN/docs/Web/API/EventTarget">EventTarget API</a>。尽管它们工作起来是相似的,但是 <code>$emit</code>、<code>$on</code>, 和 <code>$off</code> 并不是 <code>dispatchEvent</code>、<code>addEventListener</code> 和 <code>removeEventListener</code> 的别名。</p>

Expand Down Expand Up @@ -363,7 +363,7 @@ x-template 需要定义在 Vue 所属的 DOM 元素外。

<p class="tip">如果你发现你自己需要在 Vue 中做一次强制更新,99.9% 的情况,是你在某个地方做错了事。</p>

你可能还没有留意到[数组](https://v2.cn.vuejs.org/v2/guide/list.html#注意事项)[对象](https://v2.cn.vuejs.org/v2/guide/list.html#对象变更检测注意事项)的变更检测注意事项,或者你可能依赖了一个未被 Vue 的响应式系统追踪的状态。
你可能还没有留意到[数组](/v2/guide/list.html#注意事项)[对象](/v2/guide/list.html#对象变更检测注意事项)的变更检测注意事项,或者你可能依赖了一个未被 Vue 的响应式系统追踪的状态。

然而,如果你已经做到了上述的事项仍然发现在极少数的情况下需要手动强制更新,那么你可以通过 [`$forceUpdate`](../api/#vm-forceUpdate) 来做这件事。

Expand Down
2 changes: 1 addition & 1 deletion src/v2/guide/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ new Vue({

<p class="tip">不要使用对象或数组之类的非基本类型值作为 `v-for` 的 `key`。请用字符串或数值类型的值。</p>

更多 `key` attribute 的细节用法请移步至 [`key` 的 API 文档](https://v2.cn.vuejs.org/v2/api/#key)
更多 `key` attribute 的细节用法请移步至 [`key` 的 API 文档](/v2/api/#key)

## 数组更新检测

Expand Down
2 changes: 1 addition & 1 deletion src/v2/guide/reactivity.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Vue.set(vm.items, indexOfItem, newValue)
vm.items.splice(indexOfItem, 1, newValue)
```

你也可以使用 [`vm.$set`](https://v2.cn.vuejs.org/v2/api/#vm-set) 实例方法,该方法是全局方法 `Vue.set` 的一个别名:
你也可以使用 [`vm.$set`](/v2/api/#vm-set) 实例方法,该方法是全局方法 `Vue.set` 的一个别名:

``` js
vm.$set(vm.items, indexOfItem, newValue)
Expand Down
3 changes: 2 additions & 1 deletion src/v2/guide/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,15 @@ Vue Testing Library 是一组专注于测试组件而不依赖实现细节的工

- [Vue Testing Library 官网](https://testing-library.com/docs/vue-testing-library/intro)

#### Vue Test Utils
#### Vue Test Utils

Vue Test Utils 是官方的偏底层的组件测试库,它是为用户提供对 Vue 特定 API 的访问而编写的。如果你对测试 Vue 应用不熟悉,我们建议你使用 Vue Testing Library,它是 Vue Test Utils 的抽象。

**资源:**

- [Vue Test Utils 官方文档](https://vue-test-utils.vuejs.org)
- [Vue 测试指南](https://lmiller1990.github.io/vue-testing-handbook/zh-CN/) by Lachlan Miller
- [Cookbook:Vue 组件的单元测试](/v2/cookbook/unit-testing-vue-components.html)

## 端到端 (E2E) 测试

Expand Down
6 changes: 3 additions & 3 deletions src/v2/style-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ new Vue({
</summary>
{% endraw %}

细致的 [prop 定义](../guide/components-props.html#Prop-验证)有两个好处:
细致的 [prop 定义](/v2/guide/components-props.html#Prop-验证)有两个好处:

- 它们写明了组件的 API,所以很容易看懂组件的用法;
- 在开发环境下,如果向一个组件提供格式不正确的 prop,Vue 将会告警,以帮助你捕获潜在的错误来源。
Expand Down Expand Up @@ -1980,9 +1980,9 @@ Vue.component('TodoItem', {

**应该优先通过 [Vuex](https://github.com/vuejs/vuex) 管理全局状态,而不是通过 `this.$root` 或一个全局事件总线。**

通过 `this.$root` 和/或[全局事件总线](../guide/migration.html#dispatch-和-broadcast-替换)管理状态在很多简单的情况下都是很方便的,但是并不适用于绝大多数的应用。
通过 `this.$root` 和/或[全局事件总线](/v2/guide/migration.html#dispatch-和-broadcast-替换)管理状态在很多简单的情况下都是很方便的,但是并不适用于绝大多数的应用。

Vuex 是 Vue 的[官方类 flux 实现](../guide/state-management.html#类-Flux-状态管理的官方实现),其提供的不仅是一个管理状态的中心区域,还是组织、追踪和调试状态变更的好工具。它很好地集成在了 Vue 生态系统之中 (包括完整的 [Vue DevTools](../guide/installation.html#Vue-Devtools) 支持)。
Vuex 是 Vue 的[官方类 flux 实现](/v2/guide/state-management.html#类-Flux-状态管理的官方实现),其提供的不仅是一个管理状态的中心区域,还是组织、追踪和调试状态变更的好工具。它很好地集成在了 Vue 生态系统之中 (包括完整的 [Vue DevTools](/v2/guide/installation.html#Vue-Devtools) 支持)。

{% raw %}</details>{% endraw %}

Expand Down

0 comments on commit 80a0d58

Please sign in to comment.