在html教程中说:“alink(body的属性)不赞成使用。请使用样式取代它。”这个样式指的是css吗?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在html教程中说:“alink(body的属性)不赞成使用。请使用样式取代它。”这个样式指的是css吗?相关的知识,希望对你有一定的参考价值。
是的,这个样式指的就是css样式(a:active )
一、
定义:alink 属性规定文档中活动链接(active link,也就是a标签)的颜色。
实例:
<html><body alink="green">
<p><a href="#">link1</a></p>
<p><a href="#">link2</a></p>
</body>
</html>
注释:当body下的链接(active link,也就是a标签)被点击时,该链接就处于活动状态,而且颜色为green。
二、
css样式代替方案:
CSS 语法(在 <head> 部分):<style>a:active color: green</style>
实例:
<html><head>
<style>
a:active
color:green
</style>
</head>
<body>
<p><a href="#">link1</a></p>
<p><a href="#">link2</a></p>
</body>
</html>
参考资料:w3school
参考技术A alink是比较早的HTML对象了。一般用于<body>中,例如<body alink=“#0000FF”>用于指明网页中链接鼠标点击时瞬间变换的颜色。目前大家都不这么写了,是写在CSS文件里,替代的方式是
<style type="text/css">
a:active color: #0000FF
</style>
一般链接有四种状态
<style type="text/css">
a:link color: #FF0000 /*默认的链接颜色*/
a:visited color: #00FF00 /*链接被点击浏览后的颜色*/
a:hover color: #FF00FF /*鼠标经过链接时的颜色*/
a:active color: #0000FF /*鼠标点击链接时文字瞬间变化的颜色*/
</style>
为啥我在nodejs中的代码会出错并要求我写catch,但我已经在代码中说了
【中文标题】为啥我在nodejs中的代码会出错并要求我写catch,但我已经在代码中说了【英文标题】:why does my code in nodejs gives error and asks me to write catch but i have already said it in the code为什么我在nodejs中的代码会出错并要求我写catch,但我已经在代码中说了 【发布时间】:2021-04-21 05:02:40 【问题描述】:所以这是错误
(node:24077) UnhandledPromiseRejectionWarning: TypeError: Cannot set property 'id' of undefined
at Client.msg (/app/bot.js:18:22)
at Client.emit (events.js:196:13)
at MessageCreateAction.handle (/rbd/pnpm-volume/3c4dae99-ae7d-482d-8189-d37183b015d2/node_modules/.registry.npmjs.org/discord.js/12.5.1/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/rbd/pnpm-volume/3c4dae99-ae7d-482d-8189-d37183b015d2/node_modules/.registry.npmjs.org/discord.js/12.5.1/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/rbd/pnpm-volume/3c4dae99-ae7d-482d-8189-d37183b015d2/node_modules/.registry.npmjs.org/discord.js/12.5.1/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/rbd/pnpm-volume/3c4dae99-ae7d-482d-8189-d37183b015d2/node_modules/.registry.npmjs.org/discord.js/12.5.1/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/rbd/pnpm-volume/3c4dae99-ae7d-482d-8189-d37183b015d2/node_modules/.registry.npmjs.org/discord.js/12.5.1/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/rbd/pnpm-volume/3c4dae99-ae7d-482d-8189-d37183b015d2/node_modules/.registry.npmjs.org/ws/7.4.2/node_modules/ws/lib/event-target.js:132:16)
at WebSocket.emit (events.js:196:13)
at Receiver.receiverOnMessage (/rbd/pnpm-volume/3c4dae99-ae7d-482d-8189-d37183b015d2/node_modules/.registry.npmjs.org/ws/7.4.2/node_modules/ws/lib/websocket.js:825:20)
(node:24077) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:24077) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
这是代码
console.log('loding')
const Discord = require('discord.js');
const client = new Discord.Client();
const fetch = require('node-fetch')
client.login(process.env.SECRET);
client.on('ready', () =>
console.log(`Logged in as $client.user.tag!`);
);
client.on('message', msg)
async function msg()
这是 Discord 频道 ID
if (msg.channel.id = '791583092275937303' )
if (msg.content === 'ping')
msg.reply('Pong!');
else if (msg.content === '!gif')
msg.reply('gif');
let url = `https://api.tenor.com/v1/search?q=codingtrain&key=$process.env.tenor&limit=8`
wow().then(response =>
console.log('ok')
msg.reply('ok')
).catch(err =>
console.log(err);
);
async function wow()
let response = await fetch(url)
let blob = await response.json();
这是错误前的控制台
node bot.js
loding
Logged in as cybemachine#8971!
这是 Discord 服务器链接:- https://discord.gg/CvCBUsyN
【问题讨论】:
【参考方案1】:您在消息事件之外使用msg
,因此msg
未定义。您还在第一个 if 条件中说 =
,但它必须是 ===
或 ==
,因为您想知道 id 是否等于您提供的 id。仅使用=
意味着您要设置变量的值。您必须将代码更新为:
console.log('loding')
const Discord = require('discord.js');
const client = new Discord.Client();
const fetch = require('node-fetch')
client.login(process.env.SECRET);
client.on('ready', () =>
console.log(`Logged in as $client.user.tag!`);
);
client.on('message', async msg =>
if (msg.channel.id === '791583092275937303')
if (msg.content === 'ping')
msg.reply('Pong!');
else if (msg.content === '!gif')
msg.reply('gif');
let url = `https://api.tenor.com/v1/search?q=codingtrain&key=$process.env.tenor&limit=8`
wow().then(response =>
console.log('ok')
msg.reply('ok')
).catch(err =>
console.log(err);
);
async function wow()
let response = await fetch(url)
let blob = await response.json();
)
【讨论】:
没错,但顺便说一句,if (msg.channel.id = '791583092275937303')
不应该是if (msg.channel.id === '791583092275937303')
?
@DmitriyFrolov 你说得对,我错过了,对不起。编辑了我的答案。以上是关于在html教程中说:“alink(body的属性)不赞成使用。请使用样式取代它。”这个样式指的是css吗?的主要内容,如果未能解决你的问题,请参考以下文章