小编Mxk*_*ert的帖子

数组中的Vue.js搜索关键字

我正在使用Vue.js通过输入字段来过滤JSON数组中的项目。该阵列由手机组成。

看三星阵列,我有三星银河S5,三星银河S6等。

现在,当我键入:Samsung时,我会得到所有三星的列表。键入Galaxy S5时,会得到Samsung Galaxy S5。但是,当我键入Samsung S5时,我什么也没得到,因为在“ Samsung”和“ S5”之间有“ Galaxy”。

我希望有人可以帮助我解决这一问题。

我的代码:

<input type="text" v-model="keyword" class="form-control" id="telefoon" placeholder="Search...">


<script>
var app = new Vue({
  el: '#app',
  data: {
    keyword: '',
    samsungList: []
  },
  computed: {
    samsungFilteredList() {
      return this.samsungList.filter((samsung) => {
        return samsung.title.toLowerCase().includes(this.keyword.toLowerCase());
      });
    }
  }
});
</script>
Run Code Online (Sandbox Code Playgroud)

html javascript css vue.js

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

从Rest API获取JSON数据

我正在使用Rest API从网站获取数据,我想在我的网上商店中使用这些数据.我之前从未使用过API.

我现在有以下代码:

<?php 

$url = 'https://api.floraathome.nl/v1/products/get?apitoken=[MY_API_TOKEN]&type=json';
$json = file_get_contents($url);
$retVal = json_decode($json, TRUE);

for ($x = 0; $x < count($retVal); $x++) {
    echo $retVal['data'][$x]['dutchname']."<br>";
    echo $retVal['data'][$x]['purchaseprice']."<br>";
    echo $retVal['data'][$x]['promotionaltext']."<br><br>";
}
Run Code Online (Sandbox Code Playgroud)

我的问题是它只显示前两个产品,但我选择了9个产品.如果我打印$ retVal,它会输出所有9个产品.

php api json for-loop

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

Formvalidation.io - 无法读取 null 的属性“classList”

使用 formvalidation.io 时,我的控制台总是出错。

在此处输入图片说明

我不知道这个错误的原因是什么。我还在某些网站上收到垃圾邮件,即使我使用的是 backendVerificationURL。我正在使用 Invisible ReCaptcha ( https://formvalidation.io/guide/plugins/recaptcha/ )

我的 HTML 表单:

                                <form id="contact" method="post" action="/vendor/contact-form.php">
                                <div class="card-body">
                                    <div class="row">
                                        <div class="col-md-6">
                                            <div class="form-group label-floating is-empty">
                                                <label class="bmd-label-floating">Naam</label>
                                                <input type="text" name="naam" id="naam" class="form-control">
                                                <span class="material-input"></span>
                                            </div>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="form-group label-floating is-empty">
                                                <label class="bmd-label-floating">Telefoonnummer</label>
                                                <input type="text" name="telefoon" id="telefoon" class="form-control">
                                                <span class="material-input"></span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group label-floating is-empty">
                                        <label class="bmd-label-floating">Mailadres</label>
                                        <input type="email" name="email" id="email" class="form-control">
                                        <span class="material-input"></span>
                                    </div>
                                    <div class="form-group label-floating is-empty">
                                        <label for="bericht" class="bmd-label-floating">Uw bericht</label>
                                        <textarea name="bericht" …
Run Code Online (Sandbox Code Playgroud)

html javascript css formvalidation.io invisible-recaptcha

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

从 Vue.js 中的 JSON 文件导入数据而不是手动数据

这是我第一次使用 Vue.js。我制作了这个应用程序,它使用我在脚本中手动添加的数据。现在我希望能够添加一个 JSON 文件,它从中获取数据,但我不知道如何做到这一点。您可以在下面找到我的代码。

HTML:

<div id="app">

<div class="search-wrapper">
    <input type="text" v-model="keyword" placeholder="Zoek telefoon..." />
</div>

<div class="wrapper">

    <table style="width:100%; text-align: left;">
      <tr>
        <th style="text-align: left; width: 33%">Telefoon</th>
        <th style="text-align: left; width: 33%">Scherm</th> 
        <th style="text-align: left; width: 33%">Batterij</th>
      </tr>
    </table>

    <div v-for="post in filteredList">        
        <table style="width:100%; text-align: left">
          <tr style="text-align: left;">
            <td style="text-align: left; width: 33%">{{ post.title }}</td>
            <td style="text-align: left; width: 33%">{{ post.scherm }}</td> 
            <td style="text-align: left; width: 33%">{{ post.batterij }}</td>
          </tr>
        </table>
    </div>

</div>
Run Code Online (Sandbox Code Playgroud)

Vue.js:

var app = …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js vue-component axios vuejs2

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