vuejs2

What is difference between 'data:' and 'data()' in Vue.js?

偶尔善良 提交于 2021-02-05 12:56:06
问题 I have used data option in two ways. In first snippet data object contains a key value, however, in second data is a function. Is there any benefits of individuals.Not able to find relevant explanations on Vue.js Docs Here are two code snippets: new Vue({ el: "#app", data: { message: 'hello mr. magoo' } }); new Vue({ el: "#app", data() { return { message: 'hello mr. magoo' } } }); Both are giving me the same output. 回答1: It seems as though the comments on your question missed a key point when

Trigger Method in Sibling Component Vue JS

血红的双手。 提交于 2021-02-05 08:23:06
问题 need your assistance once again. Here's my situation. VueJS2 (vue-cli project) no Vuex. I have parent component, child1 and child2 . child1 is a form that gets data from child2 (which is a table). Upon clicking on table row's checkbox in child2 , we fill up the form in child1 this is done by event emitting via parent (picture 2). child1 has a button and reset method (see picture 1) to clear its fields. My task is: when I 'uncheck' checkbox in table row child2 , form in child1 has to be

odd problems in Convert Vuejs Typescript Options to Composition Api

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-05 07:45:08
问题 the problem has been solved, read through the question to see how step by step fix the problems I read about composition api(https://vue-composition-api-rfc.netlify.com/#api-introduction), and tried to convert my existing code which is based on typescript on Option api in vuejs, and i failed to make it work, and kinda confused about how composition api really work. my working code is below: <script lang="ts"> import Vue from "vue"; import {inputFields} from "@/mixins/inputField/inputField";

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

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 &&

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>

VueJS Using Prop Type Validation With NULL and 'undefined' Values?

佐手、 提交于 2021-02-04 15:48:46
问题 Even though VueJS 2 official documentation about prop validation is stating (as a code example's comment line): // Basic type check ( null and undefined values will pass any type validation) I'm getting the following error with this code reproduction — why is that? [Vue warn]: Invalid prop: type check failed for prop "value". Expected String, Number, Boolean, got Null <template> <div> <h1>{{ title }}:</h1> <MyInput :value="null" /> </div> </template> <script> Vue.component('MyInput', Vue

Why are CSS keyframe animations broken in Vue components with scoped styling?

混江龙づ霸主 提交于 2021-02-04 15:23:27
问题 I'm trying to implement a CSS typing indicator in Vue. Without Vue, it looks like this: .typing-indicator { background-color: #E6E7ED; width: auto; border-radius: 50px; padding: 20px; display: table; margin: 0 auto; position: relative; -webkit-animation: 2s bulge infinite ease-out; animation: 2s bulge infinite ease-out; } .typing-indicator:before, .typing-indicator:after { content: ''; position: absolute; bottom: -2px; left: -2px; height: 20px; width: 20px; border-radius: 50%; background

Vue 2 - How to set default type of array in props

偶尔善良 提交于 2021-02-04 12:55:48
问题 I have my Vue component, which is taking an array of objects as a prop. I often use prop validation, especially for 'default' value feature. in this case I have: props: { items: Array } but I'd like it to have like in Typescript or React: props: { items: Array.of( {key: {type: String, default: 'myText'}} ) } etc. Is it possible to achieve? Otherwise I need to use computed data as map just to set the defaults 回答1: I created example: jsFiddle, that might can help you, and yes... you can return