Vue.js

vue基础知识

╄→гoц情女王★ 提交于 2021-01-24 01:09:58
v-if 与 v-show 的区别? 在切换 v-if 块时,Vue.js 有一个局部编译/卸载过程,因为 v-if 之中的模板也可能包括数据绑定或子组件。v-if 是真实的条件渲染,因为它会确保条件块在切换当中合适地销毁与重建条件块内的事件监听器和子组件。 v-if 也是惰性的:如果在初始渲染时条件为假,则什么也不做——在条件第一次变为真时才开始局部编译(编译会被缓存起来)。 相比之下, v-show 简单得多——元素始终被编译并保留,只是简单地基于 CSS 切换。 一般来说, v-if 有更高的切换消耗而 v-show 有更高的初始渲染消耗。因此,如果需要频繁切换 v-show 较好,如果在运行时条件不大可能改变 v-if 较好。 v-if 是动态添加,当值为 false 时,是完全移除该元素,即 dom 树中不存在该元素。 v-show 仅是隐藏 / 显示,值为 false 时,该元素依旧存在于 dom 树中。若其原有样式设置了 display: none 则会导致其无法正常显示。 computed(计算属性) vs methods(方法 ) 在vue.js中,有methods和computed两种方式来动态当作方法来用的。 1.首先最明显的不同 就是调用的时候,methods要加上() 2.我们可以使用 methods 来替代 computed,效果上两个都是一样的,但是

How to use ripple-lib with nativescript

半城伤御伤魂 提交于 2021-01-23 07:05:10
问题 Dear stackoverflowers, i'm having troubles with crypto in nativescript. I want to use a NPM package ripple-lib but found no luck with nativescript-nodeify. How can I make this package work with nativescript vuejs. I Need te make use of the crypto package aswell. EDIT: If i require the package I first get an error -> Error is: Cannot find module '/Websites/repo/tests/FirebaseVuejs/platforms/ios/FirebaseVuejs/app/tns_modules/nativescript-nodeify/patch-npm-packages.js'. than if i rebuild there

How to use ripple-lib with nativescript

半城伤御伤魂 提交于 2021-01-23 07:04:06
问题 Dear stackoverflowers, i'm having troubles with crypto in nativescript. I want to use a NPM package ripple-lib but found no luck with nativescript-nodeify. How can I make this package work with nativescript vuejs. I Need te make use of the crypto package aswell. EDIT: If i require the package I first get an error -> Error is: Cannot find module '/Websites/repo/tests/FirebaseVuejs/platforms/ios/FirebaseVuejs/app/tns_modules/nativescript-nodeify/patch-npm-packages.js'. than if i rebuild there

vue+elementui后台管理快捷代码片段

烈酒焚心 提交于 2021-01-23 07:03:42
Form < el-form labelPosition ="right" labelWidth ="10%" size ="small" :model ="list" ref ="ruleForm" :rules ="rules" > < el-form-item label ="商家类型" > < el-select v-model ="traderType" @change ="change" > < el-option v-for ="item in Options" :key ="item.value" :label ="item.label" :value ="item.value" > </ el-option > </ el-select > </ el-form-item > < el-form-item label ="商家名称" prop ="name" > < el-input style ="width:50%" v-model ="list.name" ></ el-input > </ el-form-item > </ el-form > View Code Table < el-table :data ="list" width ="100%" align ="center" > < el-table-column label ="ID"

node.js vue-axios和vue-resource

心已入冬 提交于 2021-01-23 06:37:57
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>vue-resource</title> <script src="../../node_modules/"></script> <script src="../../node_modules/vue-resource/dist/vue-resource.js"></script> </head> <body> <div id="app"> <h2>vue-resource演示</h2> <a href="#" @click="sendGet">发送Get请求</a> <a href="#" @click="sendPost">发送Post请求</a> <a href="#" @click="sendJsonp">发送Jsonp请求</a> <a href="#" @click="send">全局函数</a> <p v-text="response"></p> </div> <script> new Vue({ el:"#app", data:{ response:'', msg:'' }, methods:{ sendGet: function () { var _this = this; //http://www.imooc.com

How to access data from deeply nested child components in Vue.js

半城伤御伤魂 提交于 2021-01-23 05:37:26
问题 I am building an interface using Vue.js. I have a form, this form contains an address, and other bits of miscellaneous data. So I created two components in Vue, UserData and UserAddress . UserData contains an instance of UserAddress as a child component. I want to specialize the behaviour of the "Submit" button for the form depending on the page, so these components don't contain the submit button -- the outer component, representing the page ( UserPage ) contains the submit button, and just

Vue 3 how to get information about $children

时光怂恿深爱的人放手 提交于 2021-01-23 05:02:37
问题 This my old code with VUE 2 in Tabs component: created() { this.tabs = this.$children; } Tabs: <Tabs> <Tab title="tab title"> .... </Tab> <Tab title="tab title"> .... </Tab> </Tabs> VUE 3: How can I get some information about childrens in Tabs component, using composition API? Get length, iterate over them, and create tabs header, ...etc? Any ideas? (using composition API) 回答1: To someone wanting whole code: Tabs.vue <template> <div> <div class="tabs"> <ul> <li v-for="tab in tabs" :class="{

Vue 3 how to get information about $children

大城市里の小女人 提交于 2021-01-23 04:59:29
问题 This my old code with VUE 2 in Tabs component: created() { this.tabs = this.$children; } Tabs: <Tabs> <Tab title="tab title"> .... </Tab> <Tab title="tab title"> .... </Tab> </Tabs> VUE 3: How can I get some information about childrens in Tabs component, using composition API? Get length, iterate over them, and create tabs header, ...etc? Any ideas? (using composition API) 回答1: To someone wanting whole code: Tabs.vue <template> <div> <div class="tabs"> <ul> <li v-for="tab in tabs" :class="{

Vue.js之常用指令

試著忘記壹切 提交于 2021-01-23 04:50:08
vue常用指令 vue.js官方给自己的定义是数据模板引擎,并给出了一套渲染数据的指令.本文详细介绍vue.js的常用指令. 官网: 点我 一.v-text、v-html v-text:用于绑定文本 v-html:用于绑定html < div id ="app" > < p > 姓名: < label v-text ="Name" ></ label ></ p > < p > 姓名:{{Name}} </ p > < div v-html ="Age" > 年龄: </ div > </ div > < script > new Vue({ el: " #app " , data: { Name: " corn " , Age: " <label>20</label> " } }) </ script > =======================> 姓名:corn 姓名:corn 20 1.{{Name}}这种写法和v-text的作用是相同的,用于绑定标签的text属性,如果标签没有text属性,该绑定会失效,比如在一个文本框上面使用v-text时没有效果的. 2.从结果看出,v-html绑定后会覆盖原来标签标签里面的内容,此处是覆盖,而并非append. 3.对于v-html应用时要慎重,在网站上会动态渲染任意html有一定的危险存在,因此容易导致XSS跨站脚本攻击

Vue--Vue常用指令及操作

对着背影说爱祢 提交于 2021-01-23 04:27:55
一.渲染 1. {{}}双大括号插值语法 2. v-text 3. v-html <body> <div id="app"> <p> {{message}} </p> <p v-text="text"> </p> <p v-html="title"> </p> </div> </body> </html> <script src="./js/vue.js"></script> <script> new Vue({ el:"#app", data : { message : "我是数据1,用{{}}渲染出来的" , text : "我是数据2,用v-text渲染出来的" , title : `<h4>我是数据3,用v-html渲染,还可以解析标签</h4>` } }) </script> 二、条件渲染 1. v-if 2. v-if v-else 3. v-show 4.v-if 和v-show 的区别:v-if 为 false 时此元素不存在 v-show 为 false 时 此元素为display :none <div id="app"> <p v-if="bol"> 我可以显示,因为我是true </p> <p v-if="boolean"> </p> <p v-else> 我和v-if只能显示一个,因为它是false所以我显示 </p> <p v-show="boolean"