Skip to content

Instantly share code, notes, and snippets.

@vinnitu
Last active June 10, 2020 18:13
Show Gist options
  • Save vinnitu/d9176040ac3e9cc39ca50c71dbc4cd87 to your computer and use it in GitHub Desktop.
Save vinnitu/d9176040ac3e9cc39ca50c71dbc4cd87 to your computer and use it in GitHub Desktop.
test vue3 use
<template>
<button ref='button' @click='count++' v-resize='onResize'>count is {{ count }}</button>
</template>
<script>
export default {
data () {
return {
count: 8
}
},
methods: {
onResize ({ width, height }) {
console.log('onResize', { width, height })
}
},
mounted () {
setInterval(() => {
const { clientWidth: width, clientHeight: height } = this.$refs.button
console.log('onInterval', { width, height })
}, 1000)
}
}
</script>
<div id='app'></div>
<script type='module'>
import { createApp } from 'vue'
import App from './App.vue'
const app = createApp(App)
import VueResizeObserver from 'vue-resize-observer'
app.use(VueResizeObserver)
app.mount('#app')
</script>
{
"name": "test-vue3-vite",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"vite": "^0.20.7",
"vue-resize-observer": "^1.0.32"
}
}
@vinnitu
Copy link
Author

vinnitu commented Jun 10, 2020

npm i
npx vite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment