Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
demo-vue-vuex
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Hooke
2016-10-29 21:31:06 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
31e18954c316d78c30f2541d2425692feb8638fc
31e18954
1 parent
bdbb14fa
no message
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
11 deletions
src/App.vue
src/components/child.vue
src/components/myParagraph.vue
src/App.vue
View file @
31e1895
...
...
@@ -7,16 +7,16 @@
</p>
<child :level="1">Hello world!</child>
<child :level="3">Hello world!</child>
<my-paragraph></my-paragraph>
</div>
</template>
<script>
import counter from './components/counter.vue'
import child from './components/child.vue'
import myParagraph from './components/myParagraph.vue'
import {
store
} from './main.js'
import { store } from './main.js'
export default {
name: 'app',
...
...
@@ -39,7 +39,7 @@ export default {
}
},
components: {
counter,child
counter,child
,myParagraph
}
}
</script>
...
...
src/components/child.vue
View file @
31e1895
<script>
var getChildrenTextContent = function(children) {
return children.map(function(node) {
return node.children ?
getChildrenTextContent(node.children) :
node.text
}).join('')
}
export default {
data() {
return {
}
},
computed: {
},
mounted() {
},
computed: {},
mounted() {},
methods: {},
components: {},
render: function(createElement) {
var headingId = getChildrenTextContent(this.$slots.default)
.toLowerCase()
.replace(/\W+/g, '-')
.replace(/(^\-|\-$)/g, '')
return createElement(
'h' + this.level,
this.$slots.default
[
createElement('a', {
attrs: {
name: headingId,
href: '#' + headingId
}
}, this.$slots.default)
]
)
},
props: {
...
...
src/components/myParagraph.vue
0 → 100644
View file @
31e1895
<script>
export default {
data() {
return {}
},
computed: {},
mounted() {},
methods: {},
components: {},
render: function(createElement) {
// var myParagraphVNode = createElement('p', 'hi')
// return createElement('div', [
// // Yikes - duplicate VNodes!
// myParagraphVNode, myParagraphVNode
// ])
return createElement('div',
Array.apply(null, {
length: 10
}).map(function() {
return createElement('p', 'hi')
})
)
}
}
</script>
Please
register
or
login
to post a comment