小编Ash*_*ini的帖子

Vue js中“ v-bind:value”和“ v-bind:key”之间的区别

下面是我的代码。我想使用“选择”标签,并且想从脚本中渲染选项及其值。我已经使用“ v-bind:value”来渲染脚本中的值。但是有一个错误,例如***”

[eslint-plugin-vue] [vue / require-v-for-key]迭代中的元素期望具有'v-bind:key'

指令。“ ***

因此,我给了这样的**”

< option v-for= "option in nationalityOpt" v-bind:value="option.value" v-bind:key = ""> {{ option.text }} < / option> ”。

如果我从代码中删除了“ v-bind:value”,则无法在UI中获得选项值。我想纠正“ v-bind:key”的错误,我想知道这两者之间的区别。请帮忙。

<template>
 <b-card>
    <h4 slot="header" class="card-title">Employee</h4>
        <b-row>
            <b-col sm="3">
              <b-form-group>
                <label for="name">First Name </label>
                <input type="text" id="name"  class="form-control" placeholder="Enter your name" v-model="firstName">
               </b-form-group>
            </b-col>
     </b-row>
      <b-row>
            <b-col sm="3">
              <b-form-group>
                <label for="name">Nationality</label>
                <select name="" id="" class="form-control"  placeholder="Nationality" v-model="nationality">
                  <option v-for="option in nationalityOpt" v-bind:value="option.value"> {{ option.text }} </option>
                </select>
              </b-form-group>
            </b-col>
          </b-row>
      <input type="submit" …
Run Code Online (Sandbox Code Playgroud)

vue.js vuejs2

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

如何使用 jquery 在 angular 7 中使用 bootstrap popover?

我正在尝试在 angular7 中使用 jquery 实现 bootstrap4 popover。我在 index.html 中包含了“popper.js”,也使用 npm 包含了。但它不起作用。

未捕获的类型错误:jquery__WEBPACK_IMPORTED_MODULE_2__(...).popover 不是函数

此错误仅出现在控制台中。

HTML:(sample.component.html)

<button id="option2" autocomplete="off" data-toggle="popover"> Public</button>
Run Code Online (Sandbox Code Playgroud)

Jquery: (sample.component.ts)

import { Component, OnInit } from '@angular/core';
import * as $ from 'jquery';

@Component({
  selector: 'app-sample',
  templateUrl: './sample.component.html',
  styleUrls: ['./sample.component.css']
})
export class SampleComponent implements OnInit {

  constructor() { }   
  ngOnInit() {   
    $(document).ready(function(){   
      $('[data-toggle="popover"]').popover();     
      $('#option2').popover({
         html: true,
        content: function() {
          return $("#div").html();
        },
         placement: 'bottom'
      });            
    });
  }
Run Code Online (Sandbox Code Playgroud)

如何在 angular 7 中实现 bootstrap popover?

jquery popover bootstrap-4 angular7

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

如何在vuejs中将数组值从一个函数传递给另一个函数?

我试图从" validateBeforeSubmit"函数到" saveForm "函数获取数组值.但我在" undefined"中得到" "的值arrlength.请帮我解决.

这是我在vue.js中的代码

export default {
  name: '',
  data() {
    return {}
  },
  ready: function() {
    this.validateBeforeSubmit()
    this.saveForm();
  },
  methods: {
    validateBeforeSubmit() {
      var fieldsVal = new Array();
      var firstName = document.getElementById('firstName').value
      var lastName = document.getElementById('lastName').value
      var designation = document.getElementById('designation').value

      if (firstName != "" && lastName != "" && designation != "") {
        fieldsVal.push(firstName);
        fieldsVal.push(lastName);
        fieldsVal.push(designation);
        return fieldsVal;
      } else {
        fieldsVal.length = 0;
        return fieldsVal;
      }
      return fieldsVal;
    },

    saveForm() { …
Run Code Online (Sandbox Code Playgroud)

vue.js vuejs2

0
推荐指数
1
解决办法
1043
查看次数

标签 统计

vue.js ×2

vuejs2 ×2

angular7 ×1

bootstrap-4 ×1

jquery ×1

popover ×1