/
Artalk.vue
56 lines (51 loc) · 1.56 KB
/
Artalk.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<template>
<div>
<!-- 自定义评论 -->
<h2 id="commentArea">评论</h2>
<div id="Comments"></div>
</div>
</template>
<script>
import "artalk/dist/Artalk.css";
export default {
mounted() {
if (typeof window !== "undefined") {
// 初始化Artalk
this.initArtalk();
// consoel.log("初始化Artalk");
}
},
methods: {
initArtalk() {
const ArtalkComponent = () => ({
// 需要加载的组件 (应该是一个 `Promise` 对象)
component: import("artalk")
// 异步组件加载时使用的组件
// loading: LoadingComponent,
// 加载失败时使用的组件
// error: ErrorComponent,
// 展示加载时组件的延时时间。默认值是 200 (毫秒)
// delay: 200,
// 如果提供了超时时间且组件加载也超时了,
// 则使用加载失败时使用的组件。默认值是:`Infinity`
// timeout: 3000,
});
// console.log("ArtalkComponent()=>", ArtalkComponent());
ArtalkComponent().component.then(function(result) {
// console.log("result=>", result.default);
const Artalk = result.default;
console.log("Artalk准备初始化...");
// eslint-disable-next-line no-new
new Artalk({
el: "#Comments",
pageKey: "", // 页面链接
pageTitle: "", // 页面标题
server: process.env.artalkServerUrl, // 后端地址
site: "JVue4博客"
});
console.log("Artalk初始化完成...");
});
}
}
};
</script>