Created
January 25, 2018 12:48
-
-
Save zidom/a42b51ec3c158fcefe90ee50d64d6bc7 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/podicoz
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<script src="https://cdn.jsdelivr.net/npm/vue"></script> | |
</head> | |
<body> | |
<h4>这个正常</h4> | |
<div id="app"> | |
<vlist> | |
<span slot="slot1-0">Hi</span> | |
<span slot="slot2-2">嗯哼!</span> | |
</vlist> | |
</div> | |
<h4>我怎么样才可以达到先忙的效果呢?</h4> | |
<div id="app1"> | |
<vlist> | |
<span :slot="`slot1-${index}`" slot-scope="{index}">Hi</span> | |
<span :slot="`slot2-${index}`" slot-scope="{index}">嗯哼!</span> | |
</vlist> | |
</div> | |
<script type="text/x-template" id="mylist"> | |
<ul> | |
<li v-for="(c, idx) in ['a','b','c','d']" :key='idx'> | |
{{c}}: | |
<slot :name="`slot1-${idx}`"><slot> | |
<slot :name="`slot2-${idx}`"><slot> | |
</li> | |
</ul> | |
</script> | |
<script> | |
Vue.component('vlist',{ | |
template:'#mylist' | |
}) | |
new Vue({ | |
el:'#app' | |
}) | |
new Vue({ | |
el:'#app1' | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment