vue基础入门实战

<body>
		<div id="app">
			{{message}}  
			<button v-on:click="fun1('v-on')">vue的onclick</button>
		</div>
	</body>
	<script>
		//view model
		new Vue({
			el:'#app',
			data:{
				message:'hello vue'
			},

			methods:{
				fun1:function (msg) {
					alert("hello v-on");
					this.message=msg;
				}
			}
		})
	</script>
<body>
		<div id="app">

			<input type="text" v-on:keydown="fun($event)">
			<hr/>
			传统:
			<input type="text" onkeydown="showkeyCode()">
		</div>
	</body>
	<script>
		//view model


		new Vue({
			el:'#app',
			methods:{
				fun(event){
					var keycode=event.keyCode;
					if (keycode<48 ||keycode>57){
						event.preventDefault();
					}

				}
			}
		})
		function showkeyCode() {
			var keycode=event.keyCode;
			if (keycode<48 || keycode>57){
				event.preventDefault();
			}
		}
	</script>
<body>
		<div id="app">
			<div @mouseover="fun1" id="div">
				<textarea @mouseover="fun2($event)">这是一个文件域</textarea>
			</div>
		</div>
	</body>
	<script>
		//view model

		new Vue({
			el:'#app',
			methods:{
				fun1:function () {
					alert("经过div")

				},
				fun2:function (event) {
					alert("经过文本域");
					event.stopPropagation();

				}
			}
		})
		
	</script>
	<body>
		<div id="app">
			<font size="5" :color="xy1">ddjkd</font>
			<font size="10" :color="xy2">akdk</font>
		</div>
	</body>
	<script>
		//view model
		new Vue({
			el: "#app",
			data:{
				xy1:"green",
				xy2:"red"
			}
		})
	</script>
	<body>
		<div id="app">
			<table border="1">
				<tr>
					<td>序号号</td>
					<td>编号</td>
					<td>名称</td>
					<td>价格</td>
				</tr>
				<tr  v-for="(product,index) in products">
					<td>{{index+1}}</td>
					<td>{{product.id}}</td>
					<td>{{product.name}}</td>
					<td>{{product.price}}</td>
				</tr>
				
			</table>
		</div>
	</body>
	<script>
		//view model
		new Vue({
			el:'#app',
			data:{
				products:[
						{id:1, name:"电脑", price:13},
						{id:2, name:"手机", price:14},
						{id:4, name:"平板", price:15},]
			}
		})
	</script>
<body>
		<div id="app">
			<form>
				用户<input type="text" name="name" v-model="user.username"><br/>
				密码<input type="text" name="password" v-model="user.password"><br/>
			</form>
		</div>
	</body>
	<script>
		//view model

		new Vue({
			el:'#app',
			data:{
				user:{
					username:"1234",
					password:"aaaa"
				}
			}
		})
	</script>
new Vue({
    el:'#app',
    data:{
        user:{
            id:"",
            username:"",
            password:"",
            email:"",
            age:"",
            sex:""
        },
        userList:[]
    },


    methods:{
      findall:function () {

          var _this=this;
          axios.get('/user/findAll.do')
              .then(function (response) {
                  // handle success
                _this.userList=response.data;
                  console.log(response);
              })
              .catch(function (error) {
                  // handle error
                  console.log(error);
              })

      },
        findById:function (userid) {

          var _this=this;
            axios.get('/user/findById.do', {params: {id:userid}})
                .then(function (response) {
                    _this.user=response.data;

                    $("#myModal").modal("show");
                })
                .catch(function (error) {
                    console.log(error);
                })


        },


        update:function (user) {
          var _this=this;
            axios.post('/user/updateUser.do', _this.user
            )
                .then(function (response) {
                    _this.findall();
                    console.log(response);
                })
                .catch(function (error) {
                    console.log(error);
                });
        }
    },

    created:function () {
            this.findall();
    }
})
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值