Created
February 9, 2019 11:51
-
-
Save revdfdev/bafa2dc46a2f0a58ca5327f0367eca63 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/yekogen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <script src="https://cdn.rawgit.com/zloirock/core-js/master/client/shim.min.js"></script> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| <style id="jsbin-css"> | |
| .default { | |
| background-color: grey; | |
| width: 100px; | |
| height: 100px; | |
| display: inline-block; | |
| margin: 10px; | |
| } | |
| .red { | |
| background-color: red | |
| } | |
| .blue { | |
| background-color: blue | |
| } | |
| .green { | |
| background-color: green | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.3/vue.js"></script> | |
| <div id="app"> | |
| <div id="demo1" class="default" @click="attachRed = !attachRed" :class="divClasses"></div> | |
| <div id="demo2" class="default" :class="{red: attachRed}" ></div> | |
| <div id="demo3" class="default" :class="[color, {red: attachRed}]"></div> | |
| <hr> | |
| <input type="text" v-model="color"> | |
| </div> | |
| <script id="jsbin-javascript"> | |
| new Vue({ | |
| el: "#app", | |
| data: { | |
| attachRed: false, | |
| color: "green" | |
| }, | |
| computed: { | |
| divClasses: function() { | |
| return { | |
| red: this.attachRed, | |
| blue: !this.attachRed | |
| }; | |
| } | |
| }, | |
| methods: { | |
| } | |
| }) | |
| </script> | |
| <script id="jsbin-source-css" type="text/css"> | |
| .default { | |
| background-color: grey; | |
| width: 100px; | |
| height: 100px; | |
| display: inline-block; | |
| margin: 10px; | |
| } | |
| .red { | |
| background-color: red | |
| } | |
| .blue { | |
| background-color: blue | |
| } | |
| .green { | |
| background-color: green | |
| } | |
| </script> | |
| <script id="jsbin-source-javascript" type="text/javascript">new Vue({ | |
| el: "#app", | |
| data: { | |
| attachRed: false, | |
| color: "green" | |
| }, | |
| computed: { | |
| divClasses: function() { | |
| return { | |
| red: this.attachRed, | |
| blue: !this.attachRed | |
| }; | |
| } | |
| }, | |
| methods: { | |
| } | |
| })</script></body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .default { | |
| background-color: grey; | |
| width: 100px; | |
| height: 100px; | |
| display: inline-block; | |
| margin: 10px; | |
| } | |
| .red { | |
| background-color: red | |
| } | |
| .blue { | |
| background-color: blue | |
| } | |
| .green { | |
| background-color: green | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| new Vue({ | |
| el: "#app", | |
| data: { | |
| attachRed: false, | |
| color: "green" | |
| }, | |
| computed: { | |
| divClasses: function() { | |
| return { | |
| red: this.attachRed, | |
| blue: !this.attachRed | |
| }; | |
| } | |
| }, | |
| methods: { | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment