You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/en/changeLog/index.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
# Change Log
2
2
3
-
::: tip
4
-
Although the version number uses the version number of Mettle, the content includes not only the updated content of Mettle, but also the updated content of other official tools in the same period.
5
-
:::
3
+
## v1.0.1 (Latest)
6
4
7
-
## v0.5.0 (Latest)
5
+
- A new form of function component, which is more convenient to write and more flexible.
6
+
7
+
## v0.5.0
8
8
9
9
- Added two built-in properties, `$once` and `$memo`, to optimize rendering performance.
For a better reading experience, the following code examples are all written using JSX syntax, except for the `html` API which is written using tag templates.
5
-
:::
6
-
7
-
## defineComponent
8
-
9
-
Define components.
3
+
## createApp
10
4
11
-
The first parameter is the configuration object and can be passed. Its configuration property is `mount`, which is used to mount the root component. Receives a "container" parameter, which can be an actual DOM element or a CSS selector string.
5
+
Create an application.
12
6
13
-
The second parameter is a function and must be passed. Return the HTML template. The parameter of the function is an object, and the properties of the object are `content` and `setData` respectively.
7
+
The first parameter is the root component, which is required. The second parameter is used to mount the root component. Receive a "container" parameter, which can be an actual DOM element or a CSS selector string.
14
8
15
9
```jsx
16
-
defineComponent(
17
-
{
18
-
mount:'#app',
19
-
},
20
-
() => {
21
-
return () => (
22
-
<div>
23
-
<h1>Hello Mettle</h1>
24
-
</div>
25
-
);
26
-
}
27
-
);
28
-
```
29
-
30
-
Among them, we can use `content` to define data for the component and use it when you need it.
The third parameter is optional. Its type is `Symbol` and is used with the built-in attribute `$memo` to indicate updated data.
100
69
101
-
## html
102
-
103
-
` html`` ` is a tag function. The syntax of the tag function is to directly follow the function name with a template string. For example, you can write HTML tags directly in the template string.
104
-
105
-
In the JSX syntax environment, this API will not be used.
106
-
107
-
```js
108
-
defineComponent(() => {
109
-
let count =0;
110
-
111
-
return () =>html`<p>${count}</p>`;
112
-
});
113
-
```
114
-
115
-
::: tip
116
-
If you are using the VSCode editor, you can go to the store to download the [es6-string-html](https://marketplace.visualstudio.com/items?itemName=Tobermory.es6-string-html) plug-in,
117
-
This plugin enables HTML template string highlighting.
118
-
:::
119
-
120
70
## onMounted
121
71
122
72
Register a callback function to be executed after the component is mounted.
123
73
124
74
```jsx
125
-
defineComponent(() => {
75
+
functionApp() {
126
76
onMounted(() => {
127
77
console.log('onMounted', 'about');
128
78
});
@@ -132,15 +82,15 @@ defineComponent(() => {
132
82
<h1>About</h1>
133
83
</fragment>
134
84
);
135
-
});
85
+
}
136
86
```
137
87
138
88
## onUnmounted
139
89
140
90
Registers a callback function to be called after the component instance is unmounted.
141
91
142
92
```jsx
143
-
defineComponent(() => {
93
+
functionApp() {
144
94
onUnmounted(() => {
145
95
console.log('onUnmounted', 'about');
146
96
});
@@ -150,15 +100,15 @@ defineComponent(() => {
150
100
<h1>About</h1>
151
101
</fragment>
152
102
);
153
-
});
103
+
}
154
104
```
155
105
156
106
## domInfo
157
107
158
108
Get DOM information.
159
109
160
110
```jsx
161
-
defineComponent(() => {
111
+
functionApp() {
162
112
consth1= {};
163
113
164
114
functiongetDomInfo() {
@@ -172,5 +122,23 @@ defineComponent(() => {
172
122
</h1>
173
123
</fragment>
174
124
);
175
-
});
125
+
}
126
+
```
127
+
128
+
## html
129
+
130
+
` html`` ` is a tag function. The syntax of the tag function is to directly follow the function name with a template string. For example, you can write HTML tags directly in the template string.
131
+
132
+
In the JSX syntax environment, this API will not be used.
133
+
134
+
```js
135
+
functionApp() {
136
+
let count =0;
137
+
return () =>html`<p>${count}</p>`;
138
+
}
176
139
```
140
+
141
+
::: tip
142
+
If you are using the VSCode editor, you can go to the store to download the [es6-string-html](https://marketplace.visualstudio.com/items?itemName=Tobermory.es6-string-html) plug-in,
143
+
This plugin enables HTML template string highlighting.
0 commit comments