小编Jan*_*cek的帖子

Invalid type "string | null" of template literal expression. while sending authorization

Ts-eslint stopped me with the message "Invalid type "string | null" of template literal expression" when I was trying to execute authorization.

The value came from localstorage so it has to be null or string but also I have to combine it with Bearer.

   onMounted(async ()=>{
      let myToken = localStorage.getItem('token');
      
      await axios.post(
        'http://localhost:3000/getdocuments', 
        {headers:{'Authorisation':`Baerer ${myToken}`}}
      )
      .then((res)=>{
          console.log(res);
      })
      .catch(err=>{
          console.log(err);
      })
    })

Run Code Online (Sandbox Code Playgroud)

typescript axios vuejs3

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

如何在vue中的文档上设置监听器来控制按键?

你好,我正在寻找一种在 vue 中创建监听器的方法,如下所示:

document.addEventListener('keydown', function(event){
  if(event.key === "Escape"){       
  console.log('hello esc ');
 }
});
Run Code Online (Sandbox Code Playgroud)

我需要更改“varr”的值

data(){
 return{
  varr: value
 }
}
Run Code Online (Sandbox Code Playgroud)

任何时候当用户按下 esc btn 时。但它可能用于其他情况。请帮忙。

javascript vue.js vuejs3

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

标签 统计

vuejs3 ×2

axios ×1

javascript ×1

typescript ×1

vue.js ×1