下面是我的代码。我想使用“选择”标签,并且想从脚本中渲染选项及其值。我已经使用“ 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) 我正在尝试在 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?
我试图从" 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)