Skip to content

Instantly share code, notes, and snippets.

@chihirokaasan
Last active March 19, 2018 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chihirokaasan/2f971fec0861d57bafa7d34c6e6e1153 to your computer and use it in GitHub Desktop.
Save chihirokaasan/2f971fec0861d57bafa7d34c6e6e1153 to your computer and use it in GitHub Desktop.
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