小编Nar*_*tor的帖子

如何使用从孩子传递给父母的 v-model 和 props?

我已经学习 vue 几天了,我正在尝试在孩子和父母之间传递数据/道具。现在我有以下孩子:

<template>
  <div>
    <input v-model="name1" placeholder="string">
    <input v-model="number1" placeholder="number">
    <p v-text="name1"></p>
    <p v-text="number1"></p>
  </div>
</template>

<script>
export default {
  name: "child",
  props: {
    name1 : String,
    number1 : Number
  }
}
</script>
Run Code Online (Sandbox Code Playgroud)

然后是父级:

<template>
  <div>
    <child/>
  </div>
</template>

<script>
import child from "@/components/complexComponent4/child.vue"

export default{
  name: "parent",
  components: {
    child
  }
}
</script>
Run Code Online (Sandbox Code Playgroud)

现在,当我在输入字段中输入一些文本时,它会在段落中正确显示,因为绑定到段落的道具已经更改。但是,我收到此警告:

[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 …
Run Code Online (Sandbox Code Playgroud)

vue.js

3
推荐指数
1
解决办法
7601
查看次数

$hidden 在 eloquent 模型中到底有什么作用?

我目前正在摆弄 Lumen,并使用 eloquent 进行数据库交互。我读过 Eloquent 的文档,其中有关于隐藏属性的解释:

有时您可能希望限制模型数组或 JSON 表示中包含的属性,例如密码。为此,请将 $hidden 属性添加到您的模型中:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = ['password'];
}



Alternatively, you may use the visible property to define a white-list of attributes that should be included in your model's array and JSON representation. All other attributes will be hidden when the model is converted to an array or …
Run Code Online (Sandbox Code Playgroud)

laravel eloquent lumen

3
推荐指数
1
解决办法
7832
查看次数

Vue.js 和 ES7:ReferenceError:RegeneratorRuntime 未定义

我想在我的 vue 应用程序中使用 async/await 语法。这样做时,我收到此错误:ReferenceError:regeneratorRuntime未定义

我已经在 github 上找到了指向用户 adi518 这个方向的多个解决方案: https://github.com/adi518/vue-facebook-login-component/issues/17

就语法而言,我可能会在 main.js 的顶部尝试这个,因为就责任而言,这就是您通常初始化库和 polyfill 的地方(App.vue 似乎不相关)。

So,

npm install --save regenerator-runtime
And then:

import "regenerator-runtime";
Run Code Online (Sandbox Code Playgroud)

我成功运行了 npm 安装。另外,我的 main.js 现在已将其添加到导入中: import 'regenerator-runtime';

我可以构建项目,但运行时 regeneratorRuntime 仍然不起作用,我得到相同的引用错误。我还能做什么或者我错过了什么?

node.js npm async-await vue.js babeljs

3
推荐指数
1
解决办法
2853
查看次数

“vue 入口点”在哪里?

我正在尝试在我的 vue-cli 项目中安装 bootstrap-vue。我在这里阅读https://bootstrap-vue.js.org/docs

Then, register BootstrapVue in your app entry point:

import Vue from 'vue'
import { BootstrapVue, IconsPlugin } from 'bootstrap-vue'

// Install BootstrapVue
Vue.use(BootstrapVue)
// Optionally install the BootstrapVue icon components plugin
Vue.use(IconsPlugin)
And import Bootstrap and BootstrapVue css files:

import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
Alternatively you can import Bootstrap and BootstrapVue scss files in a custom SCSS file:

@import 'node_modules/bootstrap/scss/bootstrap';
@import 'node_modules/bootstrap-vue/src/index.scss';
Make sure to import the custom.scss file in your app entry point:

import …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js bootstrap-vue

2
推荐指数
1
解决办法
3263
查看次数

将索引动态附加到属性

我有这个按钮元素:

<button v-on:click="changeRecord(element)" v-b-modal.modal-5>Aendern</button>
Run Code Online (Sandbox Code Playgroud)

它是在 v-for 循环内动态生成的。我不想像上面那样对属性名称进行硬编码,而是v-b-modal.modal-5想像这样连接它:

v-b-modal.modal-{{index}}
Run Code Online (Sandbox Code Playgroud)

有没有办法做到这一点?我正在使用 vue-cli 3 和 bootstrap-vue。

javascript bootstrap-modal vue.js bootstrap-vue

2
推荐指数
1
解决办法
416
查看次数