需求:
当前在app中不能显示用户名称的下划线,但在浏览器或者微信浏览器中打开要显示下划线.
回答:
为了根据用户是否使用app来条件性地显示下划线,你可以按照以下方式修改代码:
this.shadowRoot.querySelector('.container').innerHTML =
((_a = this.getAttribute('登录后显示文案')) === null || _a === void 0
? void 0
: _a.replace(
'XXX',
`<a href="${url}" style="text-decoration: none;color:inherit;${getCookie('appType') ? '' : 'text-decoration: underline;'}">${nickName}</a>`
)) || '';
在更新的代码中,getCookie('appType')
变量表示判断用户是否使用公司app的逻辑。如果 getCookie('appType')
为 true,则内联样式中的 text-decoration
属性将被省略,不显示下划线。否则,如果 getCookie('appType')
为 false,则 text-decoration
属性将被设置为 underline
,显示下划线