Skip to content

Instantly share code, notes, and snippets.

@lotusirous
Created August 2, 2018 07:54
Show Gist options
  • Select an option

  • Save lotusirous/53438802ad0d3b28364c1370cc72a39e to your computer and use it in GitHub Desktop.

Select an option

Save lotusirous/53438802ad0d3b28364c1370cc72a39e to your computer and use it in GitHub Desktop.
An example of vue render
/**
* 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