ã¬ã¤ã
åºæ¬çãªä½¿ãæ¹
- ã¤ã³ã¹ãã¼ã«
- ã¯ããã«
- Vue ã¤ã³ã¹ã¿ã³ã¹
- ãã³ãã¬ã¼ãæ§æ
- ç®åºããããã£ã¨ã¦ã©ããã£
- ã¯ã©ã¹ã¨ã¹ã¿ã¤ã«ã®ãã¤ã³ãã£ã³ã°
- æ¡ä»¶ä»ãã¬ã³ããªã³ã°
- ãªã¹ãã¬ã³ããªã³ã°
- ã¤ãã³ããã³ããªã³ã°
- ãã©ã¼ã å ¥åãã¤ã³ãã£ã³ã°
- ã³ã³ãã¼ãã³ãã®åºæ¬
ã³ã³ãã¼ãã³ãã®è©³ç´°
- ã³ã³ãã¼ãã³ãã®ç»é²
- ããããã£
- ã«ã¹ã¿ã ã¤ãã³ã
- ã¹ããã
- åç & éåæã³ã³ãã¼ãã³ã
- ç¹å¥ãªåé¡ã«å¯¾å¦ãã
ãã©ã³ã¸ã·ã§ã³ã¨ã¢ãã¡ã¼ã·ã§ã³
- Enter/Leave ã¨ãã©ã³ã¸ã·ã§ã³ä¸è¦§
- ç¶æ ã®ãã©ã³ã¸ã·ã§ã³
åå©ç¨ã¨æ§æ
- ããã¯ã¹ã¤ã³
- ã«ã¹ã¿ã ãã£ã¬ã¯ãã£ã
- æç»é¢æ°ã¨JSX
- ãã©ã°ã¤ã³
- ãã£ã«ã¿ã¼
ãã¼ã«
- åä¸ãã¡ã¤ã«ã³ã³ãã¼ãã³ã
- ãã¹ã
- TypeScript ã®ãµãã¼ã
- ãããã¯ã·ã§ã³ç°å¢ã¸ã®é ä¿¡
ã¹ã±ã¼ã«ã¢ãã
- ã«ã¼ãã£ã³ã°
- ç¶æ 管ç
- ãµã¼ããµã¤ãã¬ã³ããªã³ã°
- ã»ãã¥ãªãã£
å é¨
- ãªã¢ã¯ãã£ãã®æ¢æ±
移è¡
- Vue 1.x ããã®ç§»è¡
- Vue Router 0.7.x ããã®ç§»è¡
- Vuex 0.6.x ãã 1.0 ã¸ã®ç§»è¡
ãã®ä»
- ä»ã®ãã¬ã¼ã ã¯ã¼ã¯ã¨ã®æ¯è¼
- Vue.js ã³ãã¥ããã£ã¸åå ãã¾ããã!
- ãã¼ã ã«ä¼ãã
v2.x 以åã®ããã¥ã¡ã³ãã§ãã v3.x ã®ããã¥ã¡ã³ããè¦ããå ´åã¯ãã¡ã
ç¶æ ã®ãã©ã³ã¸ã·ã§ã³
æçµæ´æ°æ¥: 2020å¹´2æ25æ¥
Vue ã®ãã©ã³ã¸ã·ã§ã³ã·ã¹ãã 㯠enteringãleavingãããã³ãªã¹ããã¢ãã¡ã¼ã·ã§ã³ãããããã®å¤ãã®åç´ãªæ¹æ³ãæä¾ãã¾ãããããªãã®ãã¼ã¿èªä½ãã¢ãã¡ã¼ã·ã§ã³ãããå ´åã¯ã©ãã§ããããï¼ä¾ãã°:
- æ°å¤ã¨è¨ç®
- 表示ãããè²
- SVG ãã¼ãã®ä½ç½®
- è¦ç´ ã®ãµã¤ãºããã®ä»ã®ããããã£
ãããã¯ãã¹ã¦ãçã®æ°å¤ã¨ãã¦ä¿æããã¦ãããããããã¯æ°å¤ã«å¤æãããã¨ãå¯è½ã§ããä¸åº¦ãããããã°ãVue ã®ãªã¢ã¯ãã£ããªæ§è³ªã¨ã³ã³ãã¼ãã³ãã·ã¹ãã ã®çµã¿åããã«ãããç¶æ ããä¸éãã¬ã¼ã ãçæããããã®ãµã¼ããã¼ãã£ã®ã©ã¤ãã©ãªã使ã£ã¦ã¢ãã¡ã¼ã·ã§ã³ããããã¨ãã§ãã¾ãã
ã¦ã©ããã£ã«ããç¶æ ã®ã¢ãã¡ã¼ã·ã§ã³
ã¦ã©ããã£ã¯ãä»»æã®æ°å¤ããããã£ã®å¤åã«ãã£ã¦ä»ã®ããããã£ãã¢ãã¡ã¼ã·ã§ã³ããããã¨ãã§ããããã«ãã¾ããããã¯çè«çã«ã¯è¤éã«èãããããããã¾ããããGreenSockã使ã£ãä¾ã«æ²¡é ãã¦ã¿ã¾ããã:
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.2.4/gsap.min.js"></script>
<div id="animated-number-demo">
<input v-model.number="number" type="number" step="20">
<p>{{ animatedNumber }}</p>
</div>
new Vue({
el: '#animated-number-demo',
data: {
number: 0,
tweenedNumber: 0
},
computed: {
animatedNumber: function() {
return this.tweenedNumber.toFixed(0);
}
},
watch: {
number: function(newValue) {
gsap.to(this.$data, { duration: 0.5, tweenedNumber: newValue });
}
}
})
{{ animatedNumber }}
æ°å¤ãæ´æ°ããã¨ããã®å¤æ´ãå ¥åã®ä¸ã§ã¢ãã¡ã¼ã·ã§ã³ãã¾ããããã¯ãããã¢ã§ãããä¾ãã°æå¹ãª CSS ã®è²ã®ããã«ãç´æ¥çã«æ°å¤ã¨ãã¦ä¿æããã¦ããªããã®ã®å ´åã¯ã©ãã§ããããï¼ãã¡ãã®ããã«ãTween.js 㨠Color.js ãå ãããã¨ã«ãã£ã¦ãããæãéãããã¾ã:
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<div id="example-7">
<input
v-model="colorQuery"
v-on:keyup.enter="updateColor"
placeholder="Enter a color"
>
<button v-on:click="updateColor">Update</button>
<p>Preview:</p>
<span
v-bind:style="{ backgroundColor: tweenedCSSColor }"
class="example-7-color-preview"
></span>
<p>{{ tweenedCSSColor }}</p>
</div>
var Color = net.brehaut.Color
new Vue({
el: '#example-7',
data: {
colorQuery: '',
color: {
red: 0,
green: 0,
blue: 0,
alpha: 1
},
tweenedColor: {}
},
created: function () {
this.tweenedColor = Object.assign({}, this.color)
},
watch: {
color: function () {
function animate () {
if (TWEEN.update()) {
requestAnimationFrame(animate)
}
}
new TWEEN.Tween(this.tweenedColor)
.to(this.color, 750)
.start()
animate()
}
},
computed: {
tweenedCSSColor: function () {
return new Color({
red: this.tweenedColor.red,
green: this.tweenedColor.green,
blue: this.tweenedColor.blue,
alpha: this.tweenedColor.alpha
}).toCSS()
}
},
methods: {
updateColor: function () {
this.color = new Color(this.colorQuery).toRGB()
this.colorQuery = ''
}
}
})
.example-7-color-preview {
display: inline-block;
width: 50px;
height: 50px;
}
Preview:
{{ tweenedCSSColor }}
åçãªç¶æ ã®ãã©ã³ã¸ã·ã§ã³
Vue ã®ãã©ã³ã¸ã·ã§ã³ã³ã³ãã¼ãã³ãã使ãå ´åã¨åæ§ã«ãç¶æ ã®ãã©ã³ã¸ã·ã§ã³ã®èå¾ã«ãããã¼ã¿ã¯ãªã¿ã«ã¿ã¤ã ã«æ´æ°ã§ããããã¯ç¹ã«ãããã¿ã¤ãã³ã°ã«ããã¦ä¾¿å©ã§ãï¼åç´ãª SVG ã®ããªã´ã³ã«ä½¿ç¨ãã¦ãå¤æ°ã§å°ãéã¶ã ãã§ãããã¾ã§æãä»ãã®ãé£ããã£ãå¤ãã®å¹æãå¾ããã¾ãã
ä¸è¨ã®ãã¢ã®èå¾ã«ããå®å ¨ãªã³ã¼ãã«ã¤ãã¦ã¯ãã®ä¾ ãåç §ãã¦ãã ããã
ã³ã³ãã¼ãã³ãå ã®ãã©ã³ã¸ã·ã§ã³ã®æ´ç
å¤ãã®ç¶æ ã®ãã©ã³ã¸ã·ã§ã³ã管çãããã¨ã§ãç´ æ©ã Vue ã¤ã³ã¹ã¿ã³ã¹ãã³ã³ãã¼ãã³ãã®è¤éããå¢å ããããã¨ãã§ãã¾ãã幸ãã«ããå¤ãã®ã¢ãã¡ã¼ã·ã§ã³ã¯å°ç¨ã®åã³ã³ãã¼ãã³ãã«æ½åºã§ãã¾ããåã®ä¾ã®ã¢ãã¡ã¼ã·ã§ã³ããæ°å¤ã§ããããã£ã¦ã¿ã¾ããã:
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<div id="example-8">
<input v-model.number="firstNumber" type="number" step="20"> +
<input v-model.number="secondNumber" type="number" step="20"> =
{{ result }}
<p>
<animated-integer v-bind:value="firstNumber"></animated-integer> +
<animated-integer v-bind:value="secondNumber"></animated-integer> =
<animated-integer v-bind:value="result"></animated-integer>
</p>
</div>
// ãã®è¤éãªä¸éãã¬ã¼ã çæãã¸ãã¯ã¯ç¾å¨ãã¢ããªã±ã¼ã·ã§ã³å
ã®
// ã¢ãã¡ã¼ã·ã§ã³ããããã¨æãããããæ°å¤ã§åå©ç¨ã§ãã¾ãã
// ã³ã³ãã¼ãã³ãã¯ããããã¤ãããã¯ãªãã©ã³ã¸ã·ã§ã³ã¨è¤éãª
// ãã©ã³ã¸ã·ã§ã³æ¦ç¥ãæ§æããã¯ãªã¼ã³ãªã¤ã³ã¿ã¼ãã§ã¤ã¹ãæä¾ãã¾ãã
Vue.component('animated-integer', {
template: '<span>{{ tweeningValue }}</span>',
props: {
value: {
type: Number,
required: true
}
},
data: function () {
return {
tweeningValue: 0
}
},
watch: {
value: function (newValue, oldValue) {
this.tween(oldValue, newValue)
}
},
mounted: function () {
this.tween(0, this.value)
},
methods: {
tween: function (startValue, endValue) {
var vm = this
function animate () {
if (TWEEN.update()) {
requestAnimationFrame(animate)
}
}
new TWEEN.Tween({ tweeningValue: startValue })
.to({ tweeningValue: endValue }, 500)
.onUpdate(function () {
vm.tweeningValue = this.tweeningValue.toFixed(0)
})
.start()
animate()
}
}
})
// ãã¹ã¦ã®è¤éããã¡ã¤ã³ã® Vue ã¤ã³ã¹ã¿ã³ã¹ããåãé¤ããã¾ããï¼
new Vue({
el: '#example-8',
data: {
firstNumber: 20,
secondNumber: 40
},
computed: {
result: function () {
return this.firstNumber + this.secondNumber
}
}
})
åã³ã³ãã¼ãã³ãã®ä¸ã§ã¯ãVue ã® çµã¿è¾¼ã¿ã®ãã©ã³ã¸ã·ã§ã³ã·ã¹ãã ã«ãããã®ã¨åæã«ããã®ãã¼ã¸ã§åãæ±ã£ããããããã©ã³ã¸ã·ã§ã³æ¦ç¥ã®çµã¿åãããå©ç¨ã§ãã¾ããåæã«ãéæã§ãããã¨ã«ã¯ãããããã®å¶éãããã¾ãã
ãã¶ã¤ã³ã«å½ãå¹ãè¾¼ã
1 ã¤ã®å®ç¾©ã«ãã£ã¦ã¢ãã¡ã¼ã·ã§ã³ãããã¨ãããã¯å½ãå¹ãè¾¼ããã¨ãæå³ãã¾ããæ®å¿µãªãã¨ã«ããã¶ã¤ãã¼ãã¢ã¤ã³ã³ããã´ãããã¦ãã¹ã³ãããä½æããã¨ãããããã¯ä¸è¬çã«ç»åãéç SVG ã¨ãã¦é å¸ããã¾ãããã®ãã GitHub ã®ãªã¯ããã£ããã Twitter ã®éãé³¥ãããã¦å¤ãã®ãã®ä»ãã´ã¯çãç©ã«ä¼¼ã¦ãã¾ãããæ¬å½ã«çãã¦ããããã«ã¯ã¿ãã¾ããã
Vue ã¯ãããæå©ãã§ãã¾ãã SVG ã¯åãªããã¼ã¿ãªã®ã§ããããã®çãç©ãè奮ããããèããããã¾ãã¯é©ãããããã¨ãã«ã©ãè¦ãããã®ä¾ãå¿ è¦ãªã ãã§ãããã㦠Vue ã¯ãããã®ç¶æ éã®ãã©ã³ã¸ã·ã§ã³ãæ¯æ´ãã¦ãããªãã®ã¦ã§ã«ã«ã ãã¼ã¸ããã¼ãã£ã³ã°ã¤ã³ã¸ã±ã¼ã¿ãããã¦éç¥ãããææ çã§é åçã«ãã¾ãã
Sarah Drasner ã¯ä»¥ä¸ã®ãã¢ã§ã¿ã¤ãã¼ã¨ã¤ã³ã¿ã©ã¯ãã£ãé§åã§ã®ç¶æ å¤æ´ã®çµåããç¨ãã¦ããã示ãã¦ãã¾ã:
Pen ãè¦ã Vue-controlled Wall-E by Sarah Drasner (@sdras) on CodePen.