Skip to content

Instantly share code, notes, and snippets.

@shershen08
Created June 19, 2020 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shershen08/7b9661ef1a4bb7c1d90cbf4181add23c to your computer and use it in GitHub Desktop.
Save shershen08/7b9661ef1a4bb7c1d90cbf4181add23c to your computer and use it in GitHub Desktop.
VueJS v3 some features demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
</head>
<body>
<!-- vue -->
<div id="app"></div>
<!-- portals -->
<div id="wrapper"></div>
<script src="http://unpkg.com/vue@next"></script>
<script>
// 1 createApp syntax
const { createApp, ref } = Vue;
const App = {
// 2 data is a function
data: () => ({
someValue: false
}),
setup(props, ctx) {
const name = ref("Code");
setTimeout(() => {
name.value = 'chrysalis'
}, 1000)
return { name };
},
// 3 - multy-root
template: `
<div></div>
<h1>
Hello {{ name }} !
--
someValue: {{someValue}}
<teleport to="#wrapper">
<p v-if="true">i am in #wrapper</p>
</teleport>
</h1>`,
// 4 - explicit emit
emits: [ 'NAME_EVENT', 'remove' ]
// P ------> C
// props: {
// foo: {
// default: 'bar',
// type: String
// }
// }
// this.$emit(NAME_EVENT, {
// })
// P <------ C
};
//
createApp(App).mount("#app");
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment