Skip to content

Commit 12fd90c

Browse files
committed
update vue book
1 parent 0ff82da commit 12fd90c

File tree

13 files changed

+26
-26
lines changed

13 files changed

+26
-26
lines changed

src/vue/11.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const Fragment = Symbol('Fragment');
1414
## 1.文本类型
1515

1616
```ts
17-
render(h(Text, 'jw handsome'), document.getElementById('app'));
17+
render(h(Text, 'erxiao handsome'), document.getElementById('app'));
1818
```
1919

2020
```ts
@@ -61,7 +61,7 @@ const processText = (n1, n2, container) => {
6161

6262
```ts
6363
render(
64-
h(Fragment, [h(Text, 'hello'), h(Text, 'jw')]),
64+
h(Fragment, [h(Text, 'hello'), h(Text, 'erxiao')]),
6565
document.getElementById('app')
6666
);
6767
```

src/vue/12.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const VueComponent = {
1010
return { age: 13 };
1111
},
1212
render() {
13-
return h('p', [h(Text, "I'm Jiang sir"), h('span', this.age)]);
13+
return h('p', [h(Text, "I'm erxiao sir"), h('span', this.age)]);
1414
}
1515
};
1616
render(h(VueComponent), document.getElementById('app'));
@@ -137,7 +137,7 @@ import { render, h, Text, Fragment } from './runtime-dom.js';
137137

138138
const VueComponent = {
139139
data() {
140-
return { name: 'jw', age: 30 };
140+
return { name: 'erxiao', age: 30 };
141141
},
142142
props: {
143143
address: String
@@ -367,7 +367,7 @@ const My = {
367367
};
368368
const VueComponent = {
369369
data() {
370-
return { name: 'jw', age: 30, flag: false };
370+
return { name: 'erxiao', age: 30, flag: false };
371371
},
372372
render() {
373373
return h(Fragment, [

src/vue/13.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const VueComponent = {
2121
address: String
2222
},
2323
setup(props) {
24-
const name = ref('jw');
24+
const name = ref('erxiao');
2525
return {
2626
name,
2727
address: props.address

src/vue/14.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
const functionalComponent = (props) => {
55
return h('div', 'hello' + props.name);
66
};
7-
render(h(functionalComponent, { name: 'jw' }), app);
7+
render(h(functionalComponent, { name: 'erxiao' }), app);
88
```
99

1010
函数式组件本质就是一个函数,函数的返回值就是虚拟 DOM。 在 Vue 3 中,所有的函数式组件都是用普通函数创建的。换句话说,不需要定义 `{ functional: true }` 组件选项。

src/vue/15.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ const My = {
1414
};
1515
const VueComponent = {
1616
setup() {
17-
const state = reactive({ name: 'mrs jiang' });
17+
const state = reactive({ name: 'mrs erxiao' });
1818
provide('name', state.name);
1919
setTimeout(() => {
20-
state.name = 'jw';
20+
state.name = 'erxiao';
2121
}, 1000);
2222
return () => h(My);
2323
}

src/vue/20.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let asyncComponent = defineAsyncComponent(() => {
1313
return new Promise((resolve, reject) => {
1414
setTimeout(() => {
1515
resolve({
16-
render: () => h('div', 'hi jiang')
16+
render: () => h('div', 'hi erxiao')
1717
});
1818
}, 1000);
1919
});
@@ -47,7 +47,7 @@ let asyncComponent = defineAsyncComponent({
4747
setTimeout(() => {
4848
resolve({
4949
render() {
50-
return h('div', 'hi jiang');
50+
return h('div', 'hi erxiao');
5151
}
5252
});
5353
}, 1000);
@@ -106,7 +106,7 @@ let asyncComponent = defineAsyncComponent({
106106
setTimeout(() => {
107107
resolve({
108108
render() {
109-
return h('div', 'hi jiang');
109+
return h('div', 'hi erxiao');
110110
}
111111
});
112112
}, 3000);
@@ -168,7 +168,7 @@ let asyncComponent = defineAsyncComponent({
168168
setTimeout(() => {
169169
reject({
170170
render() {
171-
return h('div', 'hi jiang');
171+
return h('div', 'hi erxiao');
172172
}
173173
});
174174
}, 3000);

src/vue/21.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ return function render(_ctx, _cache, $props, $setup, $data, $options) {
4848
```ts
4949
const VueComponent = {
5050
setup() {
51-
let state = reactive({ name: 'jw' });
51+
let state = reactive({ name: 'erxiao' });
5252
setTimeout(() => {
5353
state.name = 'xx';
5454
}, 1000);

src/vue/24.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export function compile(template) {
5858
## 2.生成文本代码
5959

6060
```ts
61-
let r = compile('hello, jw');
61+
let r = compile('hello, erxiao');
6262
```
6363

6464
> 如果仅仅是文本直接返回即可~

src/vue/4.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pnpm install @vue/reactivity -w
1313
reactive,
1414
effect
1515
} from '/node_modules/@vue/reactivity/dist/reactivity.esm-browser.js';
16-
const state = reactive({ name: 'jw', age: 30 });
16+
const state = reactive({ name: 'erxiao', age: 30 });
1717
effect(() => {
1818
// 副作用函数 默认执行一次,响应式数据变化后再次执行
1919
app.innerHTML = state.name + '今年' + state.age + '岁了';
@@ -91,7 +91,7 @@ function createReactiveObject(target: object, isReadonly: boolean) {
9191
9292
```ts
9393
let person = {
94-
name: 'jw',
94+
name: 'erxiao',
9595
get aliasName() {
9696
return '**' + this.name + '**';
9797
}
@@ -277,7 +277,7 @@ export function triggerEffects(dep) {
277277
在渲染时我们要避免副作用函数产生的遗留
278278

279279
```ts
280-
const state = reactive({ flag: true, name: 'jw', age: 30 });
280+
const state = reactive({ flag: true, name: 'erxiao', age: 30 });
281281
effect(() => {
282282
// 副作用函数 (effect执行渲染了页面)
283283
console.log('render');

src/vue/5.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ proxy 代理的目标必须是非原始值,所以 reactive 不支持原始值
55
```typescript
66
const flag = ref(false);
77
effect(() => {
8-
document.body.innerHTML = flag.value ? 30 : '姜文';
8+
document.body.innerHTML = flag.value ? 30 : 'erxiao';
99
});
1010
setTimeout(() => {
1111
flag.value = true;
@@ -72,7 +72,7 @@ export function triggerRefValue(ref) {
7272
响应式丢失问题
7373

7474
```typescript
75-
const state = reactive({ name: 'jw', age: 30 });
75+
const state = reactive({ name: 'erxiao', age: 30 });
7676
let person = { ...state };
7777
effect(() => {
7878
document.body.innerHTML = person.name + '今年' + person.age + '岁了';

src/vue/6.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
```typescript
1010
import { reactive, effect, computed } from './reactivity.js';
11-
const state = reactive({ flag: true, name: 'jw', age: 30 });
11+
const state = reactive({ flag: true, name: 'erxiao', age: 30 });
1212
const aliasName = computed((oldValue) => {
1313
console.log('computed-run', oldValue);
1414
return '**' + state.name + '**';
@@ -20,7 +20,7 @@ const runner = effect(() => {
2020
console.log(aliasName.value);
2121
});
2222
setTimeout(() => {
23-
state.name = 'Handsome Jiang';
23+
state.name = 'Handsome erxiao';
2424
}, 1000);
2525
```
2626

src/vue/7.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function doWatch(source, cb, { deep, immediate }) {
117117
> 连续触发 watch 时需要清理之前的 watch 操作
118118
119119
```typescript
120-
const state = reactive({ flag: true, name: 'jw', age: 30 });
120+
const state = reactive({ flag: true, name: 'erxiao', age: 30 });
121121
let i = 2000;
122122
function getData(timer) {
123123
return new Promise((resolve, reject) => {
@@ -189,10 +189,10 @@ stop() {
189189
> 我们可以使用响应性属性编写一个方法,**每当它们的任何值更新时**,我们的方法就会重新运行。**`watchEffect`在初始化时也会立即运行**
190190
191191
```typescript
192-
const state = reactive({ flag: true, name: 'jw', age: 30 });
192+
const state = reactive({ flag: true, name: 'erxiao', age: 30 });
193193
watchEffect(() => (app.innerHTML = state.name));
194194
setTimeout(() => {
195-
state.name = 'Mr Jiang';
195+
state.name = 'Mr erxiao';
196196
}, 1000);
197197

198198
export function watch(source, cb, options) {

src/vue/9.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export function h(type, propsOrChildren?, children?) {
112112
} else if (l === 3 && isVNode(children)) {
113113
children = [children]; // 儿子是元素将其包装成 h('div',null,[h('span')])
114114
}
115-
return createVNode(type, propsOrChildren, children); // h('div',null,'jw')
115+
return createVNode(type, propsOrChildren, children); // h('div',null,'erxiao')
116116
}
117117
}
118118
// 注意子节点是:数组、文本、null

0 commit comments

Comments
 (0)