Skip to content

修改配置文件 #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
sidebar: 'auto',
repo: 'https://github.com/K-D-Union/Java-JavaScript-Learn-Note.git',
repoLabel: 'Github',
lastUpdated: '最近更新时间',
nav: [{
text: '首页',
link: '/'
Expand Down Expand Up @@ -57,5 +58,6 @@ module.exports = {
}]
},
],
}
},
plugins: ['@vuepress/active-header-links', '@vuepress/back-to-top']
}
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ features:
- title: 介绍
details: 写作java博客,记录日常所得。
- title: 座右铭
details: 人生最大的喜悦是每个人都说你做不到,你却完成它了!
details: 人生最大的喜悦是每个人都说你做不到,你却完成它了!
- title: Githup
details: K-D-Union,欢迎Fllow。
details: K-D-Union欢迎Fllow。
footer: Copyright © 2020-present K-D-Union
---
4 changes: 2 additions & 2 deletions docs/TypeScript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ const demo = new Demo('haocyk')
console.log(demo.name) // 'haocyka48dsi39xls2'
demo.setName('haochyk')
```
然后我们再来说一下如何使用`TypeScript`来实现一个单例模式(一个类只能被实例化一次):
然后我们再来说一下如何使用`TypeScript`来实现一个单例模式(一个类只能被实例化一次):chestnut:
``` ts
class Demo {
private static instance: Demo;
Expand All @@ -560,4 +560,4 @@ class Demo {
}
const demo = Demo.getInstance()
```
  首先我们要做的第一件事情就是控制住类的构造函数不能在外部调用,所以我们把类的构造函数设置成私有属性,这个时候该如何实例化一个类呢:monocle:,我们在类中定义一个方法提供给外部使用,由于我们没办法实例化类该怎么调用实例化类上的方法,所以我们要用`static`,直接将方法挂载到类上而不是挂载到实例化对象上,这样我们就可以通过`demo.getInstance()`来实例化`demo`这个类了,但是换句话说了,这样还不是照样可以无限实例化类嘛,实例化出来的对象指针还都不是一样的,我们接着往下看,我们在类上在通过`static`的方式挂载一个属性,将它设置为私有属性,在g`etInstance`方法中判断,如果是初始化第一次实例化这个类,我们就讲实例化对象绑定在这个`instance`属性上,最后返回出去,如果有的话,我们直接将`instance`返回出去,这样我们就实现了一个最简单的单例模式。
  首先我们要做的第一件事情就是控制住类的构造函数不能在外部调用,所以我们把类的构造函数设置成私有属性,这个时候该如何实例化一个类呢:thinking:,我们在类中定义一个方法提供给外部使用,由于我们没办法实例化类该怎么调用实例化类上的方法,所以我们要用`static`,直接将方法挂载到类上而不是挂载到实例化对象上,这样我们就可以通过`demo.getInstance()`来实例化`demo`这个类了,但是换句话说了,这样还不是照样可以无限实例化类嘛:cold_sweat:,实例化出来的对象指针还都不是一样的,我们接着往下看,我们在类上在通过`static`的方式挂载一个属性,将它设置为私有属性,在`getInstance`方法中判断,如果是初始化第一次实例化这个类,我们就讲实例化对象绑定在这个`instance`属性上,最后返回出去,如果有的话,我们直接将`instance`返回出去,这样我们就实现了一个最简单的单例模式:100:
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"docs:build": "vuepress build docs"
},
"devDependencies": {
"@vuepress/plugin-active-header-links": "^1.3.1",
"@vuepress/plugin-back-to-top": "^1.3.1",
"vuepress": "^1.0.0-rc.1"
}
}
Loading