TA的每日心情 | 开心 2019-8-21 08:44 |
---|
签到天数: 163 天 [LV.7]常住居民III
状元
- 积分
- 14980
|
加了一个纯 js 版,无需node环境。只需两个文件(index.html 和 app.js, 其实可以整成一个文件)。参看https://github.com/ffreemt/meilisearch-plaintext读我文件的最后一条。
index.html
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- </head>
- <body>
- <div>
- <div id="searchbox"></div>
- <div id="hits"></div>
- </div>
- <script src="https://cdn.jsdelivr.net/npm/@meilisearch/instant-meilisearch/dist/instant-meilisearch.umd.min.js"></script>
- <script src="https://cdn.jsdelivr.net/npm/instantsearch.js@4"></script>
- <script src="./app.js"></script>
- </body>
- </html>
复制代码
app.js
- const search = instantsearch({
- // indexName: 'steam-video-games',
- indexName: 'movies',
- searchClient: instantMeiliSearch(
- // 'https://demos.meilisearch.com',
- 'http://acone3:7700',
- 'dc3fedaf922de8937fdea01f0a7d59557f1fd31832cb8440ce94231cfdde7f25'
- ),
- })
- search.addWidgets([
- instantsearch.widgets.searchBox({
- container: '#searchbox',
- }),
- instantsearch.widgets.hits({
- container: '#hits',
- templates: {
- item: `
- <div>
- <div class="hit-name">
- <!--{{#helpers.highlight}}{ "attribute": "name" }{{/helpers.highlight}}-->
- {{#helpers.highlight}}{ "attribute": "overview" }{{/helpers.highlight}}
- ({{#helpers.highlight}}{ "attribute": "id" }{{/helpers.highlight}})
- </div>
- </div>
- `,
- },
- }),
- ])
- search.start()
复制代码
搜索界面简陋一点
|
|