当前位置: 首页 > news >正文

网站建设及优化重要性百度官网认证多少钱

网站建设及优化重要性,百度官网认证多少钱,选择网站模板注意事项,个人养老保险怎么交1、插值表达式&属性绑定 <!--template展示给用户&#xff0c;相当于MVVM模式中的V--> <template><div class"first_div">//插值表达式<p>{{ message }}</p>//这里的参数是从父组件的template里传过来的<p>{{data_1}}</p…

1、插值表达式&属性绑定

<!--template展示给用户,相当于MVVM模式中的V-->
<template><div class="first_div">//插值表达式<p>{{ message }}</p>//这里的参数是从父组件的template里传过来的<p>{{data_1}}</p>//v-开头的是vue中的指令,使用v-bind来绑定属性(单向绑定,只能将model中的数据传给绑定的属性)),可以动态改变属性值<span v-bind:title="dream">学好vue不是梦!</span></div>
</template><!--<script>模块是m和vm结合的地方-->
<script>
export default {name: "greeting.vue",//函数data() {//return返回的是一个对象,可以是后端返回的数据return {message:"这是一个插值表达式的值",dream:"小目标"//把这个绑定为标签属性值用到v-bind:}},props:{data_1:String}
}
</script>
<!--设置元素样式的模块-->
<style scoped>
.first_div p{color: red;
}
</style>

v-bind 缩写

<div id="app"><pre><a v-bind:href="url">菜鸟教程</a></pre></div><script>new Vue({el: '#app',data: {url: 'http://www.runoob.com'}})
</script>
在这里 href 是参数,告知 v-bind 指令将该元素的 href 属性与表达式 url 的值绑定。

Vue.js 为两个最为常用的指令提供了特别的缩写:

<!-- 完整语法 -->
<a v-bind:href="url"></a>
<!-- 缩写 -->
<a :href="url"></a>

2、v-if和v-show

<!--    v-if 指令将根据表达式 ifgao 的值(true 或 false )来决定是否插入 p 元素,会对DOM的新建和删除操作,增加前端开销 --><p v-if="ifgao">我是最帅的人~!!</p>
<!--    v-show 每次不会重新删除或者创建,只是改变了元素的可见属性display:none,一般会使用v-show而不是v-if--><p v-show="ifgao">我是最帅的人~!!</p>
<!--  v-if\v-else-if\v-else的用法--><p v-if="age>=70">{{username}},老人家你该休息了~</p><p v-else-if="age>=18">{{username}},欢迎光临,请开始吃鸡!~</p><p v-else>{{username}},小朋友,你的作业写完了吗!~</p>data() {return {message: "这是一个插值表达式的值",dream: "小目标",ifgao:true,username:"帅哥",age:16}

3、v-on_element_ui

 v-on 指令,它用于监听 DOM 事件:

<a v-on:click="doSomething">

在这里参数是监听的事件名。

v-on

<template><div class="first_div">
<!--    v-on:可以缩写成@--><p v-on:click="username='大佬们'">{{username}},我是v-on~</p><p @click="username='大佬们menmen'">{{username}},我是v-on~的缩写@</p><p v-on:click="changeusername">{{username}},我是v-on的函数变量~</p></div>
</template><script>
export default {name: "greeting.vue",data() {return {message: "这是一个插值表达式的值",dream: "小目标",ifgao:true,username:"帅哥",age:16}},props:{data_1:String},methods:{changeusername:function (){this.username="dalao"}},created() {console.log("实例创建之后,能够获取到this");console.log("username为:",this.username);},mounted() {console.log("vue实例挂载到dom之后")}
}
</script>

v-on 缩写

<!-- 完整语法 -->
<a v-on:click="doSomething"></a>
<!-- 缩写 -->
<a @click="doSomething"></a>

4、v-for

<table>
<tr><th v-for="(header_name,key) in project_header" v-bind:key="key">{{ header_name }}</th>
</tr>
<tr v-for="(item,key) in projects" v-bind:key="key"><td>{{ item.name }}</td><td>{{ item.leader }}</td><td>{{ item.app_name }}</td>
</tr>
</table>
</template>
<script>
export default {name: "projectlist",data(){return{project_header:["项目名称","负责人","应用名称"],projects:[{name:"吊炸天的项目",leader:"飞天小子",app_name:"很牛逼的应用"},{name:"非常厉害的项目",leader:"小旋风",app_name:"很神秘的应用"},{name:"很完美的项目",leader:"阿童木",app_name:"666的应用"}]}}
}
</script>

5、v-bind:使用v-bind来绑定属性

单向绑定,只能将model中的数据传给绑定的属性

v-model:

双向绑定:既能将model中的数据传给绑定的属性,也能将绑定的属性值传给model;

只能在input,textarea,select元素中使用;

1、插值表达式1 子组件中使用{{ msg}}插值,在<script>的export default中使用data(){return{msg:""}}传值;

2、插值表达式2 父组件中传入msg="",在子组件中使用{{ msg}}插值,在<script>的export default中使用props:{msg:String}

3、创建全局组件,在main.js文件中创建

import loginNew from "@/components/loginNew";
//创建全局组件
Vue.component('login-New',loginNew);//这样就不用在父组件内导入(import)和声明(components)子组件了
然后在App.vue根组件中调用就可以了,(不需要再去导入和声明了)
<login-New></login-New>

6、插槽

6.1 普通插槽

1、在父组件中直接调用子组件的标签,是可以渲染出子组件的内容;如果在子组件标签中添加了内容,父组件就渲染不出来了;

2、如果父组件调用的子组件标签中和子组件中的插槽中都有文本内容,那么父组件中的会覆盖子组件插槽中的内容;

index.js

以父组件为loginnew,子组件为hello-world为例;

<!--父组件loginnew.vue->>
<hello-world></hello-world>
<hello-world>这是个hello-world插槽位</hello-world>
<!--如果想要渲染出父组件中调用子组件标签中的内容,就要在子组件中添加插槽-->
<!--子组件hello-world.vue文件-->
<!--如果父组件调用的子组件标签中和子组件中的插槽中都有文本内容,那么父组件中的会覆盖子组件插槽中的内容-->
<slot><p>hello-world:我们一起学猫叫</p></slot>

6.2 具名/命名插槽

父组件loginNew.vue:

<template><div><el-form :model="ruleForm" status-icon ref="ruleForm" label-width="70px" class="demo-ruleForm":label-position="labelPosition"><el-form-item label="用户名" prop="username"><el-input type="username" v-model="ruleForm.username" autocomplete="off"></el-input></el-form-item><el-form-item label="密码" prop="password"><el-input type="password" v-model="ruleForm.password" autocomplete="off"></el-input></el-form-item><el-form-item><el-button type="primary" @click="submitForm('ruleForm')">提交</el-button><el-button @click="resetForm('ruleForm')">重置</el-button></el-form-item></el-form><!--  如果父组件调用的子组件标签中和子组件中的插槽中都有文本内容,那么父组件中的会覆盖子组件插槽中的内容--><!--  <hello-world>这是个hello-world插槽位</hello-world>--><!--  如果父组件调用的子组件标签中和子组件中的插槽中都有文本内容,那么父组件中的会覆盖子组件插槽中的内容--><!--  <hello-world></hello-world>--><hello-world><!--    方法二  命名插槽--><!--    在vue2.6之前版本--><p slot="part1">一起喵喵喵</p><!--    在vue2.6之后版本--><template v-slot:part2><p>在你面前撒个娇</p></template><!--       v-slot:可以简写成"#" --><template #part3><p>还是喵喵喵喵</p></template><!--        插槽作用域:父组件调取子组件的插槽内部要获取子组件的属性--><!--        2.6 之前--><p slot="part4" slot-scope="scope">{{ scope.user }}我得心脏砰砰跳</p><template slot="part5" slot-scope="scope"><p>{{ scope.user }}我得心脏砰砰跳aaaaaa</p></template><!--        2.6 之后--><template v-slot:part6="scope"><p>{{scope.user}}都是你的味道</p></template><template v-slot:part7="{user}"><p>{{user}}都是你的味道</p></template></hello-world></div>
</template><script>
export default {name: "loginNew",data() {return {username: "daxiao",password: "123456",labelPosition: "right",ruleForm: {username: "111",password: "222",}}},
}
</script><style scoped>
.el-form {width: 350px;margin: 50px auto;
}
</style>

子组件HelloWorld.vue:

<template><div class="hello"><h1>{{ msg }}</h1><h>{{ msg1 }}</h><p>这是一个hello-world页面</p><div><el-imagestyle="width: 300px; height: 200px":src="url"fit="cover"></el-image></div><!--    第一种方式--><!--    <slot></slot>--><!--    第二种方式--><slot><p>我们一起学猫叫</p></slot><!--    第三种方式 命名插槽--><slot name="part1"></slot><slot name="part2"></slot><slot name="part3"></slot><!--    插槽作用域--><slot name="part4" :user="username"></slot><slot name="part5" user="六啊"></slot><slot name="part6" user="七啊"></slot><slot name="part7" user="八啊"></slot><!--    <slot ></slot>--></div>
</template><script>
// import axios from 'axios';
import {dogs} from '../api/api'export default {name: 'HelloWorld',props: {msg: String},data() {return {url: '',username: "木子"}},mounted() {//方法一:不推荐// axios.get('https://dog.ceo/api/breeds/image/random')//     //如果请求成功,就会执行.then回调函数//     .then(function (response) {//       console.log('data:',response.data)//       console.log('response:',response)//       //此时的this指的是当前函数的应用//       this.url=response.data.message//     })//     //如果请求失败,就会执行.catch回调函数//     .catch(function (err) {//       console.log(err)//     });// axios.get('https://dog.ceo/api/breeds/image/random')//     //如果请求成功,就会执行.then回调函数//     //方法二:使用箭头函数//     .then(response => {//       console.log('data:', response.data)//       console.log('response:', response)//       //此时的this指的是当前函数的应用//       this.url = response.data.message//     })//     //如果请求失败,就会执行.catch回调函数//     .catch(function (err) {//       console.log(err)//     });dogs()//如果请求成功,就会执行.then回调函数//方法二:使用箭头函数.then(response => {console.log('data:', response.data)console.log('response:', response)//此时的this指的是当前函数的应用this.url = response.data.message})//如果请求失败,就会执行.catch回调函数.catch(function (err) {console.log(err)});}
}</script><!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped></style>

6.3 作用域插槽

http://www.hkea.cn/news/578784/

相关文章:

  • 许昌网站开发博客营销
  • 做网站用jquery爱站网关键词挖掘
  • wordpress手动裁剪seo营销推广服务公司
  • 英文网站建设网站海南网站制作公司
  • 网页设计与网站建设主要内容软文营销的特点
  • 一起做网站17广州最新小组排名
  • 最专业的网站设计公司有哪些论坛企业推广
  • 单页网站怎么做外链个人网页
  • 宁波城乡住房建设局网站有效的网络推广
  • 网站建设 深圳销售crm客户管理系统
  • 高端网站开发设计站长之家字体
  • 免费网站建站工具购买域名的网站
  • 淘宝联盟怎么做网站百度网站提交
  • 前端做用vue做后台多还是做网站多青岛网站快速排名优化
  • 岳阳网站开发公司海淀区seo多少钱
  • 2017年做网站维护总结百度搜索软件
  • 南京网站建设公司点击器原理
  • 网站怎么编辑搜狗网站提交入口
  • 自建网站做外贸的流程广告推广方式
  • 警告欺骗网站模板免费注册
  • 获取网站访客信息seo分析师招聘
  • 制作网页的网站有哪些网站建设
  • 日本真人做爰无遮挡视频免费网站嘉兴关键词优化报价
  • 忻州市中小企业局网站贵州整站优化seo平台
  • 网页怎么制作超链接seo兼职接单平台
  • 网站建设中应注意哪些问题重庆整站seo
  • 贵阳网站建设哪家便宜微商软文范例大全100
  • 怎么在微信上做网站竞价交易
  • wordpress优化版4.7.4网站seo设计
  • 网上课程网站精准客户数据采集软件