<template> <div id="app"> <!-- <img v-bind:src='url' /> <img :src='url' /> --> {{msg}} <br> <br> <br> <button v-on:click="run1()">执行方法的第一种写法</button> <br><br><b…
<template> <div id="app"> <!-- <img v-bind:src='url' /> <img :src='url' /> --> {{msg}} <br> <br> <br> <button v-on:click="run1()">执行方法的第一种写法</button> <br><br><b…
<template> <div id="app"> <button v-on:click="run1()">执行事件的第一种写法</button> <button @click="run2()">执行事件的第二种写法</button> <br> <br> <br> <button @click="rdata()"&…
<template> <div id="app"> <h1>{{ msg }}</h1> <br> <button v-on:click="run1()"> 第一种写法</button> <br> <button @click='run2()'> 第二种写法</button> <br> <button @click='getMsg…
1.案例实现代码如下 import React, { Component } from 'react'; /** * 特别注意this,对于传值和绑定都十分重要 */ class Home4 extends Component{ constructor(props){ super(props); //定义数据 this.state={ msg:'这是一个Home4组件', name:"杨杰" } this.getMessage = this.getMessage.bind(this);…
第三章:指令 1.语法 指令以v-打头,它的值限定为绑定表达式,它负责的是按照表达式的值应用某些行为到DOM上. 内部指令有v-show,v-else,v-model,v-repeat,v-for,v-text,v-el,v-html,v-on,v-bind,v-ref,v-pre,v-cloak,v-if. 2.内部指令 (1)控制元素的显示与否:v-if,v-show.v-else v-if是真实的条件渲染,根据表达式的true/false在DOM中生成或移除一个元素. 第一,这个指令是惰性…
第8章:过渡 1.CSS过渡 2.JavaScript过渡 3.渐进过渡 第9章:method Vue.js的事件一般通过v-on指令配置在HTML中,虽然也可以在js的代码中使用原生的addEventListener方法添加事件监听,但并不推荐,因为它并不符合"关注点分离"的设计理念. 使用v-on指令有几点好处: 通过HTML模板(视图)就能看到js对应的方法;无需手动绑定事件,ViewModel和DOM完全解耦.易于测试;当一个ViewModel被销毁时,所有的事件处理器都会被自…
React 中的 AJAX 请求:获取数据的方法 React 只是使用 props 和 state 两处的数据进行组件渲染. 因此,想要使用来自服务端的数据,必须将数据放入组件的 props 或 state 中. 首先引入 axios. 1.`import axios from 'axios';` constructor 方法非常标准,调用 super,然后初始化 state,设置一个空的 posts 数 传入新的 posts 数组,使用 this.setState 方法更新组件状态.这会导致重…
vue.js 兄弟组件之间的值传递方法 https://blog.csdn.net/jingtian678/article/details/81634149…
父组件主动获取子组件的数据和方法 1.调用子组件的时候 定义一个ref <headerchild ref="headerChild"></headerchild> 2.在父组件里面通过 this.$refs.headerChild.属性 t his.$refs.headerChild.方法 子组件主动获取父组件的数据和方法 this.$parent.属性 this.$parent.方法…