Skip to content

Instantly share code, notes, and snippets.

@revdfdev
Created February 9, 2019 12:25
Show Gist options
  • Save revdfdev/f2ef4064269c416451bae4a33f62939f to your computer and use it in GitHub Desktop.
Save revdfdev/f2ef4064269c416451bae4a33f62939f to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/yekogen
<!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" :style="{backgroundColor: color}"></div>
<div id="demo2" class="default" :style="myStyle"></div>
<div id="demo3" class="default" :style="[myStyle, {height: width + 'px'}]"></div>
<hr>
<input type="text" v-model="color">
<input type="text" v-model="width">
</div>
<script id="jsbin-javascript">
new Vue({
el: "#app",
data: {
color: "grey",
width: 100
},
computed:{
myStyle: function(){
return {
backgroundColor: this.color,
width: this.width + "px"
}
},
},
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: {
color: "grey",
width: 100
},
computed:{
myStyle: function(){
return {
backgroundColor: this.color,
width: this.width + "px"
}
},
},
methods: {
}
})</script></body>
</html>
.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
}
new Vue({
el: "#app",
data: {
color: "grey",
width: 100
},
computed:{
myStyle: function(){
return {
backgroundColor: this.color,
width: this.width + "px"
}
},
},
methods: {
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment