Skip to content

Commit 78d29c4

Browse files
committed
修复动态渲染初始dom节点无内容的错误
1 parent 68372e7 commit 78d29c4

File tree

5 files changed

+20
-9
lines changed

5 files changed

+20
-9
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A vue-based side catalog component.
99
npm install vue-side-catalog -S
1010
```
1111
## Start
12-
```
12+
```javascript
1313
<template>
1414
<div id="app">
1515
<div class="demo">
@@ -73,14 +73,15 @@ To modify this rule, you can use the **`headList`** attribute. The default value
7373
},
7474
```
7575
h1 as first-level directory:
76+
7677
![h1 as first-level directory](http://p6.qhimg.com/t0158179ba213107601.png)
7778

7879

7980
### Custom catalog elements
8081
Unlike the custom directory tags above, custom directory elements can support `elements with ref attributes` of` any level`, as well as components
8182
Requires **`refList`** properties
8283

83-
```
84+
```html
8485
<template>
8586
<h1>JavaScript</h1>
8687
<h2 ref="t1">历史</h2>
@@ -159,7 +160,7 @@ You can also use **`scrollElementSelector`** to generate a directory for the con
159160
overflow: auto;
160161
}
161162
```
162-
效果如下图
163+
The effect is as follows:
163164
![image](http://p9.qhimg.com/t01a99edbab87553234.png)
164165

165166
## Online example

README.zh-CN.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export default {
4343
> 注意: **`containerElementSelector`** 属性是必需的,指定文章的容器。
4444
4545
效果如下图:
46+
4647
![image](http://p2.qhimg.com/t0182cb51aeaebaace0.png)
4748

4849
## 示例
@@ -75,7 +76,7 @@ h1作为一级目录:
7576
跟上面的自定义目录标签不同,自定义目录元素可以支持`任意层级``含有ref属性的元素`,也可以支持组件
7677
需要用到 **`refList`** 属性
7778

78-
```
79+
```javascript
7980
<template>
8081
<h1>JavaScript</h1>
8182
<h2 ref="t1">历史</h2>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-side-catalog",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "A Catalog Component for Vue.js.",
55
"private": false,
66
"main": "lib/vue-side-catalog.umd.min",

src/App.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@
309309
</div> -->
310310
</div>
311311
<side-catalog
312+
ref="catalog"
312313
class="side-catalog"
313314
v-bind="catalogProps"
314315
>
@@ -328,8 +329,18 @@ export default {
328329
SideCatalog,
329330
// Version
330331
},
332+
mounted(){
333+
// setTimeout(()=>{
334+
// this.vhtml=`
335+
// <h1>h1</h1>
336+
// <h2>h2</h2>
337+
// <h3>n3</h3>
338+
// `;
339+
// },2000);
340+
},
331341
data() {
332342
return {
343+
vhtml:'',
333344
catalogProps: {
334345
// scrollElementSelector: '.demo',
335346
// 内容容器selector(必需)

src/components/main.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,9 @@ export default {
109109
"scroll",
110110
throttle(this.scrollHandle, 200)
111111
);
112-
// this.$nextTick(() => {
113112
setTimeout(() => {
114113
this.setWatcher();
115114
}, 500);
116-
// });
117115
},
118116
beforeDestroy() {
119117
if (this.openDomWatch) {
@@ -190,8 +188,8 @@ export default {
190188
return false;
191189
});
192190
},
193-
initActive() {
194-
// this.active = this.refList[0].ref;
191+
initActive() {
192+
if(!this.catalogList.length) return;
195193
this.active = this.catalogList[0].ref;
196194
},
197195
getTitleMargin(level) {

0 commit comments

Comments
 (0)