Skip to content

Instantly share code, notes, and snippets.

@chihirokaasan
Last active Mar 19, 2018
Embed
What would you like to do?
Vue.jsによるformのselectによるリンクメニューの実装
<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>
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