Commit ae4b5f58 authored by les's avatar les

first experiments with vue webcomponets

parent 81bbf8c2
......@@ -12,7 +12,8 @@
"doc": "cd docs && bundle exec jekyll b",
"doc:dev": "cd docs && bundle exec jekyll s --drafts",
"migrate:dev": "sequelize db:migrate",
"migrate": "NODE_ENV=production sequelize db:migrate"
"migrate": "NODE_ENV=production sequelize db:migrate",
"wc": "vue build --target wc --name gancio-event ./webcomponents/gancio-event/src/main.js"
},
"license": "AGPL-3.0",
"bugs": {
......@@ -55,6 +56,7 @@
"dependencies": {
"@nuxtjs/auth": "^4.8.5",
"@nuxtjs/axios": "^5.9.5",
"@vue/web-component-wrapper": "^1.2.0",
"accept-language": "^3.0.18",
"axios": "^0.19.2",
"bcryptjs": "^2.4.3",
......
<template lang='pug'>
div.gancio-event
h3 ciao {{event.title}}
span {{event.place.name}}
</template>
<script>
export default {
name: 'GancioEvent',
props: {
eventUrl: String
},
data () {
return {
event: { place: {} }
}
},
mounted () {
// qui dovrei fetchare event id
fetch(this.eventUrl)
.then(ret => ret.json())
.then(event => {
this.event=event
console.error(event)
})
.catch(e => console.error(e))
},
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style>
.gancio-event {
display: inline-block;
width: 300px;
border: 1px solid grey;
background-color: black;
color: white;
}
</style>
<!DOCTYPE html>
<html>
<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">
<title>My Non-Vue App</title>
</head>
<body>
<!--Load Vue-->
<script src="https://unpkg.com/vue"></script>
<!--Load the web component polyfill-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.2.0/webcomponents-loader.js"></script>
<!--Load your custom element-->
<script src="./dist/gancio-event.min.js"></script>
<!--Use your custom element-->
<gancio-event event-url='http://localhost:13120/api/event/6'></gancio-event>
</body>
</html>
import Vue from 'vue'
import wrap from '@vue/web-component-wrapper'
import GancioEvent from './GancioEvent'
const CustomElement = wrap(Vue, GancioEvent)
window.customElements.define('gancio-event', CustomElement)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment