收藏
回答

关于小程序正则表达式中文乱码问题?

 // 确保数据是字符串

        const html = typeof res.data === 'string' ? res.data : new TextDecoder('utf-8').decode(new Uint8Array(res.data));

        const regex = /<img\s+src="([^"]+)"\s+data-pic="[^"]*"[^>]*\s+alt="([^"]*)"[^>]*>/g;

        let match;

        let detailImgUrl = '';

        let altText = '';

正则表达式收集的中文会出现方框乱码,我是第一次碰到这个问题!!!uft8我也设置了 但是就是不行!!!


回答关注问题邀请回答
收藏
登录 后发表内容