expression.html 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title></title>
  5. <meta charset="utf-8">
  6. <script src="../../../dist/vue.js"></script>
  7. </head>
  8. <body>
  9. <div id="normal">
  10. <p v-text="one + ' ' + two.three + '!'"></p>
  11. <input id="one" v-model="one" name="one"> <input id="two" v-model="two.three" name="two">
  12. <button v-on="click: this.one = 'clicked'">click</button>
  13. </div>
  14. <div id="lazy">
  15. <p v-text="one + ' ' + two.three + '!'"></p>
  16. <form id="form">
  17. <input v-model="one" name="three"> <input v-model="two.three" name="four">
  18. </form>
  19. <button v-on="click: two.three = 'clicked'">click</button>
  20. </div>
  21. <div id="conditional">
  22. <p>{{ok ? yesMsg : noMsg}}</p>
  23. <button v-on="click: ok = !ok" class="toggle">toggle</button>
  24. <button v-on="click: noMsg = 'Nah'" class="change">change</button>
  25. </div>
  26. <div id="attrs" data-test="hi {{msg}} ha"></div>
  27. <div id="html">html {{{html}}} work</div>
  28. <script>
  29. Vue.config({debug:true})
  30. var normal = new Vue({
  31. el: '#normal',
  32. data: {
  33. one: 'Hello',
  34. two: {
  35. three: 'World'
  36. }
  37. }
  38. })
  39. var lazy = new Vue({
  40. el: '#lazy',
  41. lazy: true,
  42. data: {
  43. one: 'Hi',
  44. two: {
  45. three: 'Ho'
  46. }
  47. }
  48. })
  49. var conditional = new Vue({
  50. el: '#conditional',
  51. data: {
  52. ok: true,
  53. yesMsg: 'YES',
  54. noMsg: 'NO'
  55. }
  56. })
  57. var attrs = new Vue({
  58. el: '#attrs',
  59. data: {
  60. msg: 'ho'
  61. }
  62. })
  63. var html = new Vue({
  64. el: '#html',
  65. data: {
  66. html: '<p>should</p> <a>probably</a>'
  67. }
  68. })
  69. </script>
  70. </body>
  71. </html>