Last active
November 19, 2015 18:09
-
-
Save gaogao-9/c28756d1fe8d129cbcc2 to your computer and use it in GitHub Desktop.
Vue.jsでselectタグ内にComponentが入らない件について。
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>bug component</title> | |
<script src="js/vue.js"></script> | |
</head> | |
<body> | |
<h1>selectタグだと中に入らない</h1> | |
<select id="sel"> | |
<opt-component :items="items"></opt-component> | |
</select> | |
<h1>divタグだと中に入る</h1> | |
<div id="div"> | |
<opt-component :items="items"></opt-component> | |
</div> | |
<template id="opt"> | |
<option v-for="item in items" :value="$index">{{item}}</option> | |
</template> | |
<script> | |
var optComponent = Vue.extend({ | |
template: "#opt", | |
props: ["items"] | |
}); | |
var selApp = new Vue({ | |
el: "#sel", | |
data: { | |
items: [ | |
"hoge", | |
"fuga", | |
"piyo", | |
] | |
}, | |
components: { | |
optComponent | |
}, | |
}); | |
var divApp = new Vue({ | |
el: "#div", | |
data: { | |
items: [ | |
"hoge", | |
"fuga", | |
"piyo", | |
] | |
}, | |
components: { | |
optComponent | |
}, | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🍣