-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
901cb6d
commit 1dd9fbb
Showing
22 changed files
with
247 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
.DS_Store | ||
dist | ||
dist-ssr | ||
*.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Vue 3 + Vite | ||
|
||
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more. | ||
|
||
## Recommended IDE Setup | ||
|
||
- [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite App</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "vue-3-practices-debounce-answer", | ||
"description": "演習 debounce 解答", | ||
"version": "1.0.0", | ||
"author": "tuqulore Inc.", | ||
"bugs": { | ||
"url": "https://github.com/tuqulore/vue-3-practices/issues" | ||
}, | ||
"dependencies": { | ||
"vue": "^3.2.25" | ||
}, | ||
"devDependencies": { | ||
"@vitejs/plugin-vue": "^2.0.0", | ||
"throttle-debounce": "^3.0.1", | ||
"vite": "^2.7.2" | ||
}, | ||
"homepage": "https://github.com/tuqulore/vue-3-practices#readme", | ||
"keywords": [ | ||
"vue3" | ||
], | ||
"license": "MIT", | ||
"main": "", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/tuqulore/vue-3-practices.git" | ||
}, | ||
"scripts": { | ||
"build": "vite build", | ||
"dev": "vite", | ||
"dev:codesandbox": "CODESANDBOX=true vite", | ||
"preview": "vite preview" | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"infiniteLoopProtection": true, | ||
"hardReloadOnChange": false, | ||
"template": "nuxt", | ||
"container": { | ||
"port": 3000, | ||
"startScript": "dev:codesandbox", | ||
"node": "16" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<script> | ||
import {ref} from "vue" | ||
/** | ||
* throttle-debounceパッケージの使い方はドキュメントを参照しましょう | ||
* 参考: https://www.npmjs.com/package/throttle-debounce | ||
*/ | ||
import {debounce} from "throttle-debounce" | ||
export default { | ||
setup() { | ||
const input = ref("") | ||
const logs = ref([]) | ||
// debounceを使用することによって値を更新する処理の実行頻度を抑制することができます | ||
const handleInput = debounce(1000, (event) => { | ||
input.value = event.target.value | ||
logs.value.push(event.target.value) | ||
}) | ||
const handleClick = () => { | ||
logs.value = [] | ||
} | ||
return {input, logs, handleInput, handleClick} | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<p>入力履歴の1番目に「test」という文字が表示されるようにしてください</p> | ||
<input :value="input" @input="handleInput" /> | ||
<p>入力内容: {{input}}</p> | ||
<h4>入力履歴</h4> | ||
<button @click="handleClick">リセット</button> | ||
<ol> | ||
<li value="0">ここに入力履歴が追加されます</li> | ||
<li v-for="(log, index) in logs" :key="index">{{log}}</li> | ||
</ol> | ||
</template> | ||
|
||
<style> | ||
</style> |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { createApp } from 'vue' | ||
import App from './App.vue' | ||
|
||
createApp(App).mount('#app') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { defineConfig } from 'vite' | ||
import vue from '@vitejs/plugin-vue' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [vue()], | ||
...(process.env.CODESANDBOX === "true" && { | ||
server: { | ||
hmr: { | ||
port: 443 | ||
} | ||
} | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
.DS_Store | ||
dist | ||
dist-ssr | ||
*.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Vue 3 + Vite | ||
|
||
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more. | ||
|
||
## Recommended IDE Setup | ||
|
||
- [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite App</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "vue-3-practices-debounce", | ||
"description": "演習 debounce", | ||
"version": "1.0.0", | ||
"author": "tuqulore Inc.", | ||
"bugs": { | ||
"url": "https://github.com/tuqulore/vue-3-practices/issues" | ||
}, | ||
"dependencies": { | ||
"vue": "^3.2.25" | ||
}, | ||
"devDependencies": { | ||
"@vitejs/plugin-vue": "^2.0.0", | ||
"throttle-debounce": "^3.0.1", | ||
"vite": "^2.7.2" | ||
}, | ||
"homepage": "https://github.com/tuqulore/vue-3-practices#readme", | ||
"keywords": [ | ||
"vue3" | ||
], | ||
"license": "MIT", | ||
"main": "", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/tuqulore/vue-3-practices.git" | ||
}, | ||
"scripts": { | ||
"build": "vite build", | ||
"dev": "vite", | ||
"dev:codesandbox": "CODESANDBOX=true vite", | ||
"preview": "vite preview" | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"infiniteLoopProtection": true, | ||
"hardReloadOnChange": false, | ||
"template": "nuxt", | ||
"container": { | ||
"port": 3000, | ||
"startScript": "dev:codesandbox", | ||
"node": "16" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<script> | ||
import {ref} from "vue" | ||
/** | ||
* throttle-debounceパッケージの使い方はドキュメントを参照しましょう | ||
* 参考: https://www.npmjs.com/package/throttle-debounce | ||
*/ | ||
import {debounce} from "throttle-debounce" | ||
export default { | ||
setup() { | ||
const input = ref("") | ||
const logs = ref([]) | ||
const handleInput = (event) => { | ||
input.value = event.target.value | ||
logs.value.push(event.target.value) | ||
} | ||
const handleClick = () => { | ||
logs.value = [] | ||
} | ||
return {input, logs, handleInput, handleClick} | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<p>入力履歴の1番目に「test」という文字が表示されるようにしてください</p> | ||
<input :value="input" @input="handleInput" /> | ||
<p>入力内容: {{input}}</p> | ||
<h4>入力履歴</h4> | ||
<button @click="handleClick">リセット</button> | ||
<ol> | ||
<li value="0">ここに入力履歴が追加されます</li> | ||
<li v-for="(log, index) in logs" :key="index">{{log}}</li> | ||
</ol> | ||
</template> | ||
|
||
<style> | ||
</style> |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { createApp } from 'vue' | ||
import App from './App.vue' | ||
|
||
createApp(App).mount('#app') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { defineConfig } from 'vite' | ||
import vue from '@vitejs/plugin-vue' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [vue()], | ||
...(process.env.CODESANDBOX === "true" && { | ||
server: { | ||
hmr: { | ||
port: 443 | ||
} | ||
} | ||
}) | ||
}) |