Created
January 26, 2018 08:34
-
-
Save zidom/04877f3caa2e51e5fcebc9c53f4b2c8b to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/riyatef
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> | |
<style> | |
li{ | |
margin-bottom: 10px; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="app"> | |
<ve-list :list="works"> | |
<!-- what? why?how? --> | |
<work-viewer slot="viewer-0" slot-scope="{item}" :work="item"></work-viewer> | |
<work-editor slot="editor-0" slot-scope="{item}" :work="item"></work-editor> | |
<work-viewer slot="viewer-1" slot-scope="{item}" :work="item"></work-viewer> | |
<work-editor slot="editor-1" slot-scope="{item}" :work="item"></work-editor> | |
<work-viewer slot="viewer-2" slot-scope="{item}" :work="item"></work-viewer> | |
<work-editor slot="editor-2" slot-scope="{item}" :work="item"></work-editor> | |
<work-viewer slot="viewer-3" slot-scope="{item}" :work="item"></work-viewer> | |
<work-editor slot="editor-3" slot-scope="{item}" :work="item"></work-editor> | |
</ve-list> | |
</div> | |
<script type="text/x-template" id="veList"> | |
<ul> | |
<li v-for="(item, idx) in list" :key='idx'> | |
<div class="wrapper" style="border: solid 1px #ff6000"> | |
<slot :name="`viewer-${idx}`" :item="item"></slot> | |
<slot :name="`editor-${idx}`" :item="item"></slot> | |
</div> | |
</li> | |
</ul> | |
</script> | |
<script type="text/x-template" id="work_editor"> | |
<div style="background-color: antiquewhite"> | |
Editor: <strong>{{this.work.title}}</strong>! | |
</div> | |
</script> | |
<script type="text/x-template" id="work_viewer"> | |
<div style="background-color: cornflowerblue"> | |
Viewer: <strong>{{this.work.title}}</strong>! | |
</div> | |
</script> | |
<script> | |
Vue.component('veList', { | |
template: '#veList', | |
props: { | |
list: { | |
type: Array, | |
default: [] | |
} | |
} | |
}) | |
Vue.component('work-editor', { | |
template: '#work_editor', | |
props: ['work'] | |
}) | |
Vue.component('work-viewer', { | |
template: '#work_viewer', | |
props: ['work'] | |
}) | |
new Vue({ | |
el: '#app', | |
data() { | |
return { | |
works: [{ | |
id: 1, | |
title: 'work1' | |
}, { | |
id: 2, | |
title: 'work2' | |
}, { | |
id: 3, | |
title: 'work3' | |
}] | |
} | |
} | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment