web -- Navigator.vibrate(); 使設備(有振動硬件)產生有頻率的振動

MDN 文檔javascript

此方法須要用戶手勢。 不然,它返回false。html

const koa2 = require(`koa2`);
const Router = require(`koa-router`);
const router = new Router();
const app = new koa2();

const Index = router.get(`/`, async (ctx, next) =>{
  await next()
  ctx.status = 200;
  ctx.type= `html`;
  ctx.body = `
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <h1 id="h">hello2</h1>
    <script>
      document.getElementById('h').onclick = function(e){
         window.navigator.vibrate([200, 100]);
      }
    </script>
    `
}).routes();
app.use(Index);

app.listen(1995);
相關文章
相關標籤/搜索