Skip to content

Commit f8546f7

Browse files
authored
Merge pull request #1 from waylau/feat/add-demos
Feat/add demos
2 parents 5f37830 + 9df166f commit f8546f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+176973
-1
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* [开启第一个Vue.js 3应用](https://developer.huawei.com/consumer/cn/forum/topic/0201493946596180265?fid=23)
1616
* [探索Vue 3应用](https://developer.huawei.com/consumer/cn/forum/topic/0201493947940070266?fid=23)
1717
* [Vue 3使用TypeScript](https://developer.huawei.com/consumer/cn/forum/topic/0202494862427410279?fid=23)
18+
* [Vue 3组件与Web组件的异同点](https://developer.huawei.com/consumer/cn/forum/topic/0202525033799260635?fid=23)
19+
* [Vue 3动态组件详解](https://developer.huawei.com/consumer/cn/forum/topic/0204533696955760004?fid=23)
1820
* 未完待续...
1921

2022
## Samples 示例
@@ -24,6 +26,12 @@
2426
* [Hello World with TypeScript](samples/hello-world-with-ts)
2527
* [TypeScript Demos](samples/typescript-demos)
2628
* [生命周期钩子的例子](samples/vue-lifecycle)
29+
* [Vue.js组件的示例](samples/basic-component)
30+
* [组件的复用](samples/basic-component-reusable)
31+
* [监听子组件事件](samples/listen-for-child-component-event)
32+
* [通过插槽分发内容](samples/slot-to-serve-as-distribution-outlets-for-content)
33+
* [动态组件](samples/dynamic-component)
34+
* [keep-alive使用示例](samples/dynamic-component-with-keep-alive)
2735
* 未完待续...
2836

2937

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
5+
6+
# local env files
7+
.env.local
8+
.env.*.local
9+
10+
# Log files
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
pnpm-debug.log*
15+
16+
# Editor directories and files
17+
.idea
18+
.vscode
19+
*.suo
20+
*.ntvs*
21+
*.njsproj
22+
*.sln
23+
*.sw?
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# basic-component-reusable
2+
3+
## Project setup
4+
```
5+
npm install
6+
```
7+
8+
### Compiles and hot-reloads for development
9+
```
10+
npm run serve
11+
```
12+
13+
### Compiles and minifies for production
14+
```
15+
npm run build
16+
```
17+
18+
### Lints and fixes files
19+
```
20+
npm run lint
21+
```
22+
23+
### Customize configuration
24+
See [Configuration Reference](https://cli.vuejs.org/config/).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
presets: [
3+
'@vue/cli-plugin-babel/preset'
4+
]
5+
}

samples/basic-component-reusable/package-lock.json

+29,254
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "basic-component-reusable",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"serve": "vue-cli-service serve",
7+
"build": "vue-cli-service build",
8+
"lint": "vue-cli-service lint"
9+
},
10+
"dependencies": {
11+
"core-js": "^3.6.5",
12+
"vue": "^3.0.0",
13+
"vue-class-component": "^8.0.0-0"
14+
},
15+
"devDependencies": {
16+
"@typescript-eslint/eslint-plugin": "^4.18.0",
17+
"@typescript-eslint/parser": "^4.18.0",
18+
"@vue/cli-plugin-babel": "~4.5.0",
19+
"@vue/cli-plugin-eslint": "~4.5.0",
20+
"@vue/cli-plugin-typescript": "~4.5.0",
21+
"@vue/cli-service": "~4.5.0",
22+
"@vue/compiler-sfc": "^3.0.0",
23+
"@vue/eslint-config-typescript": "^7.0.0",
24+
"babel-eslint": "^10.1.0",
25+
"eslint": "^6.7.2",
26+
"eslint-plugin-vue": "^7.0.0",
27+
"typescript": "~4.1.5"
28+
},
29+
"eslintConfig": {
30+
"root": true,
31+
"env": {
32+
"node": true
33+
},
34+
"extends": [
35+
"plugin:vue/vue3-essential",
36+
"eslint:recommended",
37+
"@vue/typescript"
38+
],
39+
"parserOptions": {
40+
"parser": "@typescript-eslint/parser"
41+
},
42+
"rules": {}
43+
},
44+
"browserslist": [
45+
"> 1%",
46+
"last 2 versions",
47+
"not dead"
48+
]
49+
}
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
8+
<title><%= htmlWebpackPlugin.options.title %></title>
9+
</head>
10+
<body>
11+
<noscript>
12+
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
13+
</noscript>
14+
<div id="app"></div>
15+
<!-- built files will be auto injected -->
16+
</body>
17+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<template>
2+
<HelloWorld msg="basic component"/>
3+
<HelloWorld msg="basic component reusable"/>
4+
</template>
5+
6+
<script lang="ts">
7+
import { Options, Vue } from 'vue-class-component';
8+
import HelloWorld from './components/HelloWorld.vue';
9+
10+
@Options({
11+
components: {
12+
HelloWorld,
13+
},
14+
})
15+
export default class App extends Vue {}
16+
</script>
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<template>
2+
<div class="hello">
3+
<h1>{{ msg }}</h1>
4+
</div>
5+
</template>
6+
7+
<script lang="ts">
8+
import { Options, Vue } from 'vue-class-component';
9+
10+
@Options({
11+
props: {
12+
msg: String
13+
}
14+
})
15+
export default class HelloWorld extends Vue {
16+
msg!: string
17+
}
18+
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createApp } from 'vue'
2+
import App from './App.vue'
3+
4+
createApp(App).mount('#app')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* eslint-disable */
2+
declare module '*.vue' {
3+
import type { DefineComponent } from 'vue'
4+
const component: DefineComponent<{}, {}, any>
5+
export default component
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"compilerOptions": {
3+
"target": "esnext",
4+
"module": "esnext",
5+
"strict": true,
6+
"jsx": "preserve",
7+
"importHelpers": true,
8+
"moduleResolution": "node",
9+
"experimentalDecorators": true,
10+
"allowJs": true,
11+
"skipLibCheck": true,
12+
"esModuleInterop": true,
13+
"allowSyntheticDefaultImports": true,
14+
"sourceMap": true,
15+
"baseUrl": ".",
16+
"types": [
17+
"webpack-env"
18+
],
19+
"paths": {
20+
"@/*": [
21+
"src/*"
22+
]
23+
},
24+
"lib": [
25+
"esnext",
26+
"dom",
27+
"dom.iterable",
28+
"scripthost"
29+
]
30+
},
31+
"include": [
32+
"src/**/*.ts",
33+
"src/**/*.tsx",
34+
"src/**/*.vue",
35+
"tests/**/*.ts",
36+
"tests/**/*.tsx"
37+
],
38+
"exclude": [
39+
"node_modules"
40+
]
41+
}

samples/basic-component/.gitignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
5+
6+
# local env files
7+
.env.local
8+
.env.*.local
9+
10+
# Log files
11+
npm-debug.log*
12+
yarn-debug.log*
13+
yarn-error.log*
14+
pnpm-debug.log*
15+
16+
# Editor directories and files
17+
.idea
18+
.vscode
19+
*.suo
20+
*.ntvs*
21+
*.njsproj
22+
*.sln
23+
*.sw?

samples/basic-component/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# basic-component
2+
3+
## Project setup
4+
```
5+
npm install
6+
```
7+
8+
### Compiles and hot-reloads for development
9+
```
10+
npm run serve
11+
```
12+
13+
### Compiles and minifies for production
14+
```
15+
npm run build
16+
```
17+
18+
### Lints and fixes files
19+
```
20+
npm run lint
21+
```
22+
23+
### Customize configuration
24+
See [Configuration Reference](https://cli.vuejs.org/config/).
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
presets: [
3+
'@vue/cli-plugin-babel/preset'
4+
]
5+
}

0 commit comments

Comments
 (0)