Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head></head>
- <body>
- <div id='testfunction' class="bg-dark">
- <span v-html="globalFun2"></span>
- <button v-on:click='randFun'>refresh</button>
- </div>
- <script type="text/javascript">
- // alias to fix missing console.info
- console.info = function(text) {
- console.log(text)
- }
- </script>
- <!-- include vue 3 -->
- <script src="https://unpkg.com/vue@next"></script>
- <!-- simple Vue3 app -->
- <script type="text/javascript">
- const appFunction = Vue.createApp({
- data(){
- return {
- globalFun1:'hello fun 1',
- globalFun2:'<h2>hello fun 2</h2>',
- textFun:''
- }
- },
- methods:{
- randFun(){
- const rand = Math.random();
- if (rand <= 0.5){
- alert(this.globalFun1)
- }else{
- alert(this.globalFun2);
- }
- }
- }
- })
- appFunction.mount('#testfunction');
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement