Created
October 4, 2018 14:46
-
-
Save CompuIves/0ad8ab1c66ccf3ebdef909d403f4bb44 to your computer and use it in GitHub Desktop.
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
import * as React from "react"; | |
import * as Vue from "vue/dist/vue"; | |
import VueElement from "./VueElement"; | |
import { PropertyControls, ControlType } from "framer"; | |
// Define type of property | |
interface Props { | |
text: string; | |
} | |
export class VueComponent extends React.Component<Props> { | |
el; | |
componentWillReceiveProps(nextProps) { | |
Object.keys(nextProps).forEach(key => { | |
try { | |
this.e.componentInstance[key] = nextProps[key]; | |
} catch (e) { | |
console.log(key); | |
console.log(e); | |
} | |
}); | |
} | |
mountVue = el => { | |
this.el = this.el || el; | |
this.vue = new Vue({ | |
el: this.el, | |
render: h => { | |
this.e = h(VueElement, { | |
props: this.props | |
}); | |
return this.e; | |
} | |
}); | |
}; | |
render() { | |
return ( | |
<div> | |
<div ref={this.mountVue} /> | |
</div> | |
); | |
} | |
} |
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
import * as Vue from "vue/dist/vue"; | |
// Define a new component called button-counter | |
export default Vue.component("button-counter", { | |
data: function() { | |
return { | |
count: 0 | |
}; | |
}, | |
props: ["width", "height"], | |
template: | |
"<div v-bind:style=\"{ width: width + 'px', height: height + 'px', backgroundColor: 'blue'}\"><button v-on:click=\"count++\">You clicked me {{height}}{{width}} {{ count }} times.</button></div>" | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment