-
-
Save chihirokaasan/2f971fec0861d57bafa7d34c6e6e1153 to your computer and use it in GitHub Desktop.
Vue.jsによるformのselectによるリンクメニューの実装
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
<div id="target"> | |
<select v-model="selected" v-on:change="jump"> | |
<option v-for="option in options" v-bind:value="option.value"> | |
{{ option.text }} | |
</option> | |
</select> | |
</div> |
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
new Vue({ | |
el: '#target', | |
data: { | |
selected: '', | |
options: [ | |
{ text: '選択してください', value: '' }, | |
{ text: 'Yahoo', value: 'https://www.yahoo.co.jp/' }, | |
{ text: 'Google', value: 'https://www.google.co.jp/' } | |
] | |
}, | |
methods: { | |
jump: function(e){ | |
location.href = e.target.value; | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment