Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An alternative to Vue template and Vue JSX

License

NotificationsYou must be signed in to change notification settings

egoist/vue-html

Repository files navigation

NPM versionNPM downloadsBuild Status

Use tagged template string in Vue.js render function

Why is this useful?

If you want to use Vue without a bundler / transpiler, this library will (reasonably) make your app smaller:

  • Vue (runtime + template compiler): 32kB gzipped
  • Vue (runtime + vue-html): 23kB gzipped

What's the downside? No handy sugars likev-model support.

Install

$ npm install --save vue-html

CDN versions:

Usage

Edit vue-html-example

importVuefrom'vue'importHTMLfrom'vue-html'Vue.use(HTML)constTodos={props:['todos'],render(html){returnhtml`<ul>${this.todos.map((todo,index)=>{returnhtml`<likey=${index}>${todo}</li>            `})}</ul>    `}}newVue({el:'#app',data:{todos:['Conquer the world','Rewrite Peco'],todo:''},methods:{add(){this.todos.push(this.todo)this.todo=''}},render(html){returnhtml`<div><inputvalue=${this.todo}onInput=${e=>(this.todo=e.target.value)}/><buttontype="button"onClick=${this.add}>Add</button><hr/><${Todos}todos=${this.todos}/></div>    `}})

The usage is very similar to Vue JSX except that thehtml function is powered byHTM (Hyperscript Tagged Markup).

Using Components

constApp={render(html){returnhtml`<div><${Todos}/><${Todos}> or with children<//></div>    `}}

You can also use the traditional way of using local / global components:

constApp={render(html){returnhtml`<div><Todos/></div>    `},components:{    Todos}}

Contributing

  1. Fork it!
  2. Create your feature branch:git checkout -b my-new-feature
  3. Commit your changes:git commit -am 'Add some feature'
  4. Push to the branch:git push origin my-new-feature
  5. Submit a pull request :D

License

MIT ©EGOIST

About

An alternative to Vue template and Vue JSX

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp