UNPKG

can

Version:

MIT-licensed, client-side, JavaScript framework that makes building rich web applications easy.

45 lines (37 loc) 844 B
<body> <mock-url></mock-url> <script> steal = { forceES5: false }; </script> <script id="demo-source" main="@empty" src="../../node_modules/steal/steal.js" dev-bundle> import { ObservableObject, route, stache, stacheBindings, type } from "can"; import "can/demos/technology-overview/mock-url"; class Counter extends ObservableObject { static get props() { return { count: { default: 0, type: type.convert(Number), set(newValue) { return newValue || 0; } } }; } increment() { this.count += 1; } } window.myCounter = new Counter(); route.data = myCounter; route.start(); const view = stache(` <button on:click="this.increment()">+1</button> Count: <span>{{ this.count }}</span> `); document.body.appendChild( view(myCounter) ); </script> </body> <style> body { margin: 0px; padding: 0px; } </style>