Created
August 2, 2018 07:54
-
-
Save lotusirous/53438802ad0d3b28364c1370cc72a39e to your computer and use it in GitHub Desktop.
An example of vue render
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
| /** | |
| * Mixins patter | |
| for create other components | |
| * @param {*} heading level for example h1, h2 | |
| */ | |
| export function generateTitle(level) { | |
| return { | |
| render: function(createElement) { | |
| return createElement( | |
| `h${level}`, | |
| { | |
| attrs: { | |
| style: "color: red", | |
| ref: "container" | |
| } | |
| }, | |
| this.$slots.default // Get the rest DOM nodes | |
| ); | |
| }, | |
| props: { | |
| level: { | |
| type: Number, | |
| default: level // level from param | |
| } | |
| } | |
| }; | |
| } | |
| // Expose type | |
| export const MyTitle = generateTitle(1); | |
| export const MyMediumTitle = generateTitle(2); | |
| export default { | |
| MyTitle, | |
| MyMediumTitle | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment