Vue.js

VueJS - How to update component data from a function inside a method?

允我心安 提交于 2021-02-05 06:40:27
问题 I'm trying to do a search using Firebase. I have this in my VueJS Code. export default { data () { return { listings: [], searchData: { keyword: "" } } }, name: 'SearchScreen', components: { ValidationProvider, ValidationObserver }, firebase: { listings: listingsRef }, methods: { search () { console.log(this.searchData.keyword) listingsRef.orderByChild('location').equalTo(this.searchData.keyword).on('value', function (snapshot){ console.log(snapshot.val()) return{ listings: snapshot.val() } }

How to add SVG image to vuetify text field

我只是一个虾纸丫 提交于 2021-02-05 06:11:06
问题 I am using vuetify and would like to add an SVG icon to the start of the text field. I know you can prepend or append icons from v-icon, but I would like to use my own SVG image in a similar way. 回答1: Just use the "prepend" slot: <v-text-field label="My text field" type="text"> <template v-slot:prepend> <img width="24" height="24" src="[PathToAssets]/whatever.svg" > </template> </v-text-field> 回答2: You can read about the public path I would strongly recommend using the public path: Add your

Vue component not showing in laravel

会有一股神秘感。 提交于 2021-02-05 05:23:24
问题 So I'm trying to migrate my jquery to vue framework instead, I'm using laravel 5.6 with webpack to build my project but my vue components are not showing up. when I run command npm run dev I succesfully build the project: After that I use php artisan serve to show the web in my browser wich it does but NONE of the components show up. When I check source code this is what the component renders : but for some reason I can't see the component? This is my app.js file: /** * First we will load all

vuex

ぃ、小莉子 提交于 2021-02-04 23:01:58
vuex是一个专门为vue.js设计的集中式状态管理架构。状态?我把它理解为在data中的属性需要共享给其他vue组件使用的部分,就叫做状态。简单的说就是data中需要共用的属性。比如:我们有几个页面要显示用户名称和用户等级,或者显示用户的地理位置。如果我们不把这些属性设置为状态,那每个页面遇到后,都会到服务器进行查找计算,返回后再显示。在中大型项目中会有很多共用的数据,所以尤大神给我们提供了vuex。 (vuex官网)[ https://vuex.vuejs.org/zh-cn/ ] 小demo练手 引入vuex 学vuex我同样还是用的vue-cli模板 1.利用npm包管理工具,进行安装 vuex。在控制命令行中输入下边的命令就可以了。 npm install vuex --save 需要注意的是这里一定要加上 –save,因为你这个包我们在生产环境中是要使用的。 2.新建一个vuex文件夹(这个不是必须的),并在文件夹下新建store.js文件,文件中引入我们的vue和vuex import Vue from 'vue'; import Vuex from 'vuex' 3.使用我们vuex,引入之后用Vue.use进行引用。 Vue.use(Vuex) 通过这三步的操作,vuex就算引用成功了 demo demo截图: 1.现在我们store.js文件里增加一个常量对象

Truncate and show or hide the link text when clicking on “read more” link

微笑、不失礼 提交于 2021-02-04 21:56:26
问题 I want to hide the text if limit exceed to 300 chars and show the link and if click on link then show the full content. html: <tr v-for="(row,index) in datasource"> <td v-for="column in gridSchema.grid.columns" class="wrap-break-word" v-show="column.isVisible"> <span v-if="row[column.headername].length >= 300 && toggle == false" v-html="$options.filters.limitTo(row[column.headername])"> </span><a v-on:click="toggleFlag()" v-show="!row['isEditable'] && row[column.headername].length >= 300 &&

How to use v-model inside v-for loop in Vue js

坚强是说给别人听的谎言 提交于 2021-02-04 21:42:30
问题 this is my first question here, I'm really desperate and I hope you can help me. I'm trying to build a post/comment/reply system like Facebook by using vuejs, I'm using v-for to loop all posts/comments/replies after I use Axios to fetch data in my database (using laravel API), the problem here that I have input with v-model attached to a form inside my v-for loops when I type in my of my input it appears in all other inputs that has been looped here is an image for better understanding ->

How to use v-model inside v-for loop in Vue js

泄露秘密 提交于 2021-02-04 21:42:21
问题 this is my first question here, I'm really desperate and I hope you can help me. I'm trying to build a post/comment/reply system like Facebook by using vuejs, I'm using v-for to loop all posts/comments/replies after I use Axios to fetch data in my database (using laravel API), the problem here that I have input with v-model attached to a form inside my v-for loops when I type in my of my input it appears in all other inputs that has been looped here is an image for better understanding ->

前端性能优化总结

情到浓时终转凉″ 提交于 2021-02-04 19:35:43
前言 最近花了一些时间在项目的性能优化上,背后做了很多工作,但是最后依然没有达到自己想要的结果,有些失望,但是还是记录下自己的执着。 性能优化总结:减少请求次数、减小资源大小、提高响应和加载速度、优化资源加载时机、优化加载方式。 性能分类 对前端工程性能的优化,我觉得可以分为两类: 站在用户视角的主观的可感知的性能。 站在开发者视角的可客观度量的性能。 感知性能 对于用户来说,用户的感知性能才是最重要的,简单讲,就是让用户感觉你的网站访问很快,并且感知性能没有衡量标准。 不过,凡事总有例外,如果一个页面的加载时间就会很长,我们也可以通过一些方式让用户觉得没有那么慢。 总之一句话,你的页面可以做的不快,但是你可以让你的用户觉得你很快。 客观性能 对于开发者来说,性能指标是可以客观度量的,我们可以通过一些手段来优化 Web 性能,使这些度量指标达到开发者设定的标准。 客观性能是指,从用户输入url开始,到下载、解析和执行所有资源以及最终绘制的整个过程的时间度量。 性能指标是个很复杂的标准,后续我会单独整理出一篇文章介绍性能指标。 构建优化 由于我司使用的是 @vue/cli ,所以许多webpack配置脚手架已经帮你完成了,我就不叙述了,这里只讲基于 @vue/cli 做的一些优化配置 gzip 压缩 gzip 压缩效率非常高,通常可以达到 70% 的压缩率,也就是说,如果你的网页有

Bootstrap-vue issue with b-nav-item, can't change color

本秂侑毒 提交于 2021-02-04 19:22:12
问题 If I put this code into the Template portion of the playground at https://bootstrap-vue.js.org/play, I cannot get my 'A Number Here (1)' text to be red. Is there any way to color the text of one b-nav-item so it isn't the same as the others? <b-navbar toggleable="md" type="dark" variant="dark"> <b-navbar-toggle target="nav_collapse"></b-navbar-toggle> <b-collapse is-nav id="nav_collapse"> <b-navbar-nav> <b-nav-item href="#">Nav Item 1</b-nav-item> <b-nav-item href="#">Nav Item 2</b-nav-item>

How to get elementById in Nativescript?

我与影子孤独终老i 提交于 2021-02-04 18:56:35
问题 I'm using nativescript with vue.js and I'm trying to do something like DOM operation. This is sample code from my template: <Label textWrap="true"> <FormattedString id="formString" backgroundColor="yellow" effectiveHeight="100" effectiveWidth="100%"> <Span text="This text has a " /> </FormattedString> </Label> I want to get tag element FormattedString by his id - formString In javascript is like this: let fs = doument.getElementById('formString'); How can I do this in Nativescript-Vue? I know