Vue.js

How do you import a JSON file with VueJS / Typescript?

社会主义新天地 提交于 2021-02-19 01:43:10
问题 I just created a clean VueJS new project and I can't get loading a JSON file to work. Reproduction / Issue For easy reproduction I've created a Github repo with my issue: https://github.com/devedse/VueJSImportJsonFile In the Home.vue page I'm trying to get Json loading to work. (https://github.com/devedse/VueJSImportJsonFile/blob/master/src/views/Home.vue) When you open this solution in VSCode the following line shows an error: import theJson from '@/assets/hi.json'; Can't find module '@

nativescript passing props vue

 ̄綄美尐妖づ 提交于 2021-02-19 01:42:39
问题 Having trouble passing a prop in nativescript this.$navigateTo() <template> <stack-layout v-for="meme in memes"> <Image :src="meme.url" @tap="goToEditPage(meme.url)"/> </stack-layout> </template> <script> import EditMeme from './EditMeme' export default { computed: { memes(){ return this.$store.getters.memes } }, components: { EditMeme }, methods: { goToEditPage(ImageUrl) { this.$navigateTo(EditMeme, { context: { propsData: { Image: ImageUrl } }}); } } } </script> I tried passing props this

Matching query param in vue routes

流过昼夜 提交于 2021-02-19 01:29:50
问题 Is there any way to route by a query param? I would like to match the following route: site.com/?foo=123 . I've tried things like { path: '/\?foo=[\d]*' } without success. 回答1: Unfortunately, you can't match a query param in the path string of a route definition. Vue Router uses path-to-regexp , and its documentation says: The RegExp returned by path-to-regexp is intended for use with pathnames or hostnames. It can not handle the query strings or fragments of a URL. You can use regular

VueJS error Avoid mutating a prop directly

大憨熊 提交于 2021-02-18 21:53:09
问题 I'm trying to create a modal but I'm getting this error only when I close it: [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "value" found in ---> <PanelDesconectarModal> at resources\assets\vue\PanelDesconectarModal.vue <VNavigationDrawer> <PanelDrawer> at resources\assets\vue\PanelDrawer.vue <VApp> <PanelRoot> at resources\assets

vue教程

拥有回忆 提交于 2021-02-18 20:59:51
vue-cli 实战总结 https://juejin.im/post/5a1a6a6551882534af25a86b http://www.runoob.com/vue2/vue-tutorial.html 来源: oschina 链接: https://my.oschina.net/u/437465/blog/3035568

Vue.js 实战教程(附demo)

时光怂恿深爱的人放手 提交于 2021-02-18 20:36:33
在实战之前,你需要对vuejs的基础语法有一定的了解,可以通过以下几个途径进行学习: vue.js官方文档: https://cn.vuejs.org/v2/guide/index.html vue.js 教程: https://www.mingtern.com/course/vuejs/ 官方的文档内容比较多且杂,对于初学者来说可能没有系统性的引导,可以查看明灯小站的基础教程,对一些常用的基础语法都进行了整理,还可以在线进行调试。 好了,如果你对基础语法有一定的了解了,那就可以开始我们的实战项目了,这次我们要做的是一个简单的webapp,课程中会使用原生的vuejs语法,有非常详细的解释,对于小白用户来说,可以轻松掌握。 正式开始之前,可能你还需要对flex布局有一定的了解,可以查看阮一峰大神的两个教程,也非常简单。 Flex 布局教程:语法篇 Flex 布局教程:实例篇 Pure vue demo教程列表 Pure vue demo 实战第一节:Vue基础一 Pure vue demo 实战第二节:Vue基础二 Pure vue demo 实战第三节:Vue组件 Pure vue demo 实战第四节:Vue实例的生命周期 Pure vue demo 实战第五节:数据获取 来源: oschina 链接: https://my.oschina.net/u/4352408/blog

Computed property reactive to window.innerwidth in VueJS

匆匆过客 提交于 2021-02-18 20:29:54
问题 Basically, what I need is a computed property that returns true when the window.innerwidth is equal or lower than 768px and false when it's higher than 768px. What I did: computed: { isMobile() { if (window.innerWidth <= 768) { return true } return false } } But that computes that property only once, and if I resize the window later, it doesn't react to that change. What can I do? 回答1: Add an eventlistener to the window like so: new Vue({ el: "#app", data() { return { windowWidth: window

On key press of Enter, click a button in vuejs

左心房为你撑大大i 提交于 2021-02-18 20:29:27
问题 Here is my fiddle: DEMO There is a button called "fb-send", which has to get clicked on key press on "enter" in the input field. How to achieve this? <input @keyup.enter="" placeholder="Reply here" class="fb-comment-input" /> <i class="material-icons fb-button-right fb-send">⇨</i> Any help would be much appreciated. Thank you. 回答1: You can also call method for fb_send directly on input field: @keyup.enter="enterClicked()" 回答2: Here is my answer fiddle: ANSWER-DEMO I solved this using $refs.

Getting bootstrap vue pagination to play with REST api

南楼画角 提交于 2021-02-18 20:01:12
问题 Trying to get Bootstrap Vue to play with a REST api that returns data for one page and the total number of records (based on this): <template> </div> <b-pagination v-on:change="onPageChange" :total-rows="totalRows" :per-page="perPage" v-model="currentPage" /> <b-table responsive striped hover show-empty stacked="md" :items="items" :fields="fields" :current-page="currentPage" :per-page="perPage" :filter="filter" :sort-by.sync="sortBy" :sort-desc.sync="sortDesc" :sort-direction="sortDirection"

Binding method result to v-model with Vue.js

别说谁变了你拦得住时间么 提交于 2021-02-18 19:49:38
问题 How do you bind a method result to a v-model with Vue.js? example : <someTag v-model="method_name(data_attribute)"></someTag> I can't make it work for some reason. Thank you. 回答1: v-model expressions must have a get and set function. For most variables this is pretty straight forward but you can also use a computed property to define them yourself like so: data:function(){ return { value: 5 } }, computed: { doubleValue: { get(){ //this function will determine what is displayed in the input