vue 기본 1:

21570 단어

1,vue
1,vue :
2,vue :
3, - (data)
4, — filters,

5,
6. :
7,
8.
9, ( )


1,vue
html+css+js 。 js jq
| | vue
2,drf
Django ,
| | , , , | , ,
3,
vue , drf
Git| | celery


1,vue :
vue :
vue , :Angular、React、Vue
# vue js
# , vue : , ,
vue :
, , , , ,MVVM 、 、
vue :
vue : cdn
1, ( vue)

2,cdn


2,vue :
1, — ( HTML )
1,vue :
2、vue : 、cdn
3、vue : 、 API、 、 、MVVM 、 、
4、vue html : ****

ps:
1,html body
2, vue , id



{{ }}



{{ }}




{{ }}



<br> new Vue({<br> el:'.main' //el <br> });<br> new Vue({<br> el: '#wrap' // el id <br> })<br>


js ( ) :
let b = 20;
let dic = {
a: 10, // ,key
b // , key , b:b b key, b
};
console.log(dic)

3, - (data)
1, data vue , {}
2, {{}} , key
3, app, ( $ ),
app.$data.info
4, APP
app.info
5, vue methods , ,this.info(this info)




{{ info }}


{{ info }}


{{ num }}


{{ arr }}


{{ dic }}




<br> let app = new Vue({<br> el: '#app',<br> data: {<br> info: 'message',<br> num: 100,<br> result: true,<br> arr: [1, 2, 3, 4, 5],<br> dic: {<br> name: 'Owen',<br> age: 17.5<br> }<br> }<br> })<br>
<br> console.log(app);<br> console.log(app.$data.info); // info $data.info $<br> console.log(app.info); // app.$data.info , , $data <br>

4, — filters,
1, , ,
2, {{... | (... )}}
3, filters ( )




{{ num + 3.5 }}


{{ msg.split('')[4] }}



{{ num | f1 }}


{{ 10, 20, 30, 40 | f2 }}


{{ 10, 20 | f2(50, 80) }}


{{ 120 | f2 }}




<br> new Vue({<br> el: '#app',<br> data: {<br> num: 100,<br> msg: 'message'<br> },<br> filters: {<br> // :{{ num | f1 }}<br> f1: function (num) {<br> return num * 2<br> },<br> // :{{ a,b,c,d | f2 }} {{ a,b,c | f2(d) }} { a,b| f2(c,d) }} { a| f2(b,c,d) }}<br> f2: function (a, b, c, d) {<br> console.log(a, b, c, d);<br> return a + b + c + d // <p>{{ 120 | f2 }}</p> a 120,b,c,d undefined NaN<br> }<br> }<br> })<br>

5,
1, v-text ,
2,v-html html , html
3,


{{ info }}
















<br> new Vue({<br> el: '#app',<br> data: {<br> info: 'data ',<br> }<br> })<br>


// 1) js ``
// 2) , `${ }`
let s1 = `

`;
console.log(s1);

let name = 'Owen';
let age = 17.5;
let s2 = `
name: ${name}
age: ${age}
`;
console.log(s2);


6. :
:v-on: =' ( )’
:@ =' ( )'
methods
: | () | ( )





<br/> <style><br> body {<br> /* */<br> user-select: none;<br> }<br> .low-num {<br> cursor: pointer;<br> }<br> .low-num:hover {<br> color: red;<br> }<br> </style><br/> <br/> <br/> <div id="app"><br/> <!-- :v-on: =" " --><br/> <p class="low-num" v-on:click="lowNum"><br/> <span> :</span><br/> <span>{{ num }}</span><br/> </p><br/><br/> <p v-on:dblclick="dblAction"> </p><br/><br/> <!-- v-on: =" " @ =" " --><br/> <p> </p> // , , , <br/> <p> 1</p> // <br/> <p> 2</p><br/> <p> 3</p> // , , $event<br/><br/> <!-- :<br> @ =' ' $event<br> @ =' ()' ,<br> @ =' ( ...)' <br> @ =' ($event, ...)' <br> --><br/> </div><br/> <br/> <script src="js/vue.js"/><br/> <script><br> let app = new Vue({<br> el: '#app',<br> data: {<br> num: 99<br> },<br> methods: {<br> lowNum: function () {<br> // vue , <br> // alert(this.num)<br> this.num -= 1;<br> },<br> dblAction (ev) {<br> // alert(' ');<br> console.log(ev)<br> },<br> overAction(a, b, c) {<br> console.log(a, b, c)<br> }<br> }<br> })<br> </script><br/><br/> <br/> :<p> </p><br/> <br/> : , <br/> : this. <br/> : ,<br/> 7, <br/> // 1) :v-bind: =" "<br/> // 2) v-bind: =" " : =" "<br/> // 3) : :title=" " | :id=" " | : =" "<br/> // 4) style : :style=" " | :style="{css 1: 1, ..., css n: n}"<br/> // 5) class : :class=" " | :class="[ 1, ..., n]" | :calss="{ : }"<br/><br/> <br/> <br/> <br/> <meta charset="UTF-8"/><br/> <title>





1


2



vue 1



vue 2





1


2




3


4



5









<br> new Vue({<br> el: '#app',<br> data: {<br> p1: 'q1',<br> myStyle: {<br> backgroundColor: 'pink',<br> color: 'deeppink',<br> 'border-radius': '50%'<br> },<br> c1: 'cyan',<br> c2: 'tan',<br> myc1: 'ccc ddd eee',<br> myc2: 'ccc1',<br> myc3: 'ccc2',<br> myc4: 'ccc3',<br> yyy: true, // false<br> },<br> methods: {<br> clickAction() {<br> this.yyy = !this.yyy;<br> }<br> }<br> })<br>


8. :




<br/> <style><br> .box {<br> width: 200px;<br> height: 200px;<br> <br> }<br> .center {<br> text-align: center;<br> line-height: 200px;<br> }<br> .rcenter {<br> text-align: right;<br> line-height: 200px;<br> }<br> .right {<br> text-align: right;<br> }<br> .top {<br> line-height: 21px;<br> }<br> .bottom {<br> line-height: calc(400px - 21px);<br> }<br> </style><br/> <br/> <br/> <div id="app"><br/> <div class="box" :class="[c1, {right:r, top:t, bottom:b}]">{{ msg }}</div><br/> </div><br/> <br/> <script src="js/vue.js"/><br/> <script><br> new Vue({<br> el: '#app',<br> methods: {<br> a1(){<br> this.msg = ' ';<br> // <br> this.c1 = 'center';<br> this.r = 0;<br> this.t = 0;<br> this.b = 0;<br> },<br> a2(){<br> this.msg = ' ';<br> // <br> this.r = 1;<br> this.t = 1;<br> this.b = 0;<br> },<br> a3(){<br> this.msg = ' ';<br> // <br> this.c1 = 'rcenter';<br> this.r = 0;<br> this.t = 0;<br> this.b = 0;<br> },<br> a4(){<br> this.msg = ' ';<br> // <br> this.r = 1;<br> this.t = 0;<br> this.b = 1;<br> },<br> },<br> data: {<br> msg: '',<br> c1: '',<br> r:0,<br> t:0,<br> b:0,<br> }<br> })<br> </script><br/> <br/> 9, ( )<br/> // 1) :v-model=" vaule "<br/> // 2) :value=" " ( , )<br/> // 3) v-model=" " ( , )<br/> // 4) ,v-model <br/> // 5) ,v-model ( ), ( )<br/> // 6) ,v-model ( , )<br/> <br/> <br/> <br/> <br/> <meta charset="UTF-8"/><br/> <title/><br/> <style><br> .p1 {<br> width: 500px;<br> height: 21px;<br> background-color: orange;<br> }<br> </style><br/> <br/> <br/> <div id="app"><br/> <form action=""><br/> <!--1) value , --><br/> <input class="inp1" type="text" :value="info"/><br/> <input class="inp2" type="text" :value="info"/><br/> <p class="p1">{{ info }}</p><br/> <hr/><br/> <!--2) v-model=" " , value, --><br/> <input class="inp1" type="text" v-model="info"/><br/> <input class="inp2" type="text" v-model="info"/><br/> <p class="p1">{{ info }}</p><br/> <hr/><br/> <!-- 2) v-model - --><br/> :<input type="checkbox" name="agree" v-model="isAgree"/><br/> <!-- :<input type="checkbox" name="agree" true-value="yes" false-value="no" v-model="isAgree">--><br/> <p>{{ isAgree }}</p><br/> <br/> <!-- 3) --><br/> :<br/> <input type="radio" name="sex" value="male" v-model="mysex"/><br/> <input type="radio" name="sex" value="female" v-model="mysex"/><br/> <input type="radio" name="sex" value="others" v-model="mysex"/><br/> <p>{{ mysex }}</p><br/> <br/> <br/> <!-- 4) --><br/> :<br/> <input type="checkbox" name="hobbies" value="male" v-model="myhobbies"/><br/> <input type="checkbox" name="hobbies" value="female" v-model="myhobbies"/><br/> <input type="checkbox" name="hobbies" value="others" v-model="myhobbies"/><br/> <p>{{ myhobbies }}</p><br/> <br/> <br/> <hr/><br/> <input type="submit"/><br/> </form><br/> </div><br/> <br/> <script src="js/vue.js"/><br/> <script><br> new Vue({<br> el: '#app',<br> data: {<br> info: '123',<br> isAgree: 0,<br> // isAgree: 'no',<br> mysex: 'others',<br> myhobbies: ['male', 'female']<br> }<br> })<br> </script><br/> </code></pre> </div> </div> </div>

좋은 웹페이지 즐겨찾기