Use vue+typescript to build a project, and after introducing weixin-js-sdk, you can't use the methods inside?

problem description

use vue+typescript "s vue-cli3.0 to build a project and want to share with Wechat. After introducing weixin-js-sdk, import wx from "weixin-js-sdk" in the page. As a result, underfined, is displayed when wx is printed, but in the same way used in vue-cli2.0, normal objects can be printed

.

related codes

import wx from "weixin-js-sdk";
export default class Index extends Vue {
mounted () {

console.log(wx);

}
}

sources of topics and their own ideas

this question has perplexed me for several days. Today, I just found out that it is the problem of cli3.0. I am not very familiar with TS. I am looking for help from God to answer this question. Thank you!

Aug.07,2021

const wx = window ['wx']


const wx: any = (' wx' in window) & & window ['wx']

Menu