×ðÁú¿­Ê±¹ÙÍøµÇ¼

jsÔõôµ¼ÈëͼƬ

ÔÚ javascript Öе¼ÈëͼƬÓÐÁ½ÖÖÒªÁ죺ʹÓà ±êÇ©£¬Ö¸¶¨Í¼Æ¬Â·¾¶£¬¼òÆÓÒ×Óá£Ê¹Óà image ¹¤¾ß£¬ÔÊÐí¶¯Ì¬¼ÓÔغͶÔͼÏñ¾ÙÐвÙ×÷£¬µ«¸üÖØ´ó¡£

ÔõÑùÔÚ JavaScript Öе¼ÈëͼƬ

ÔÚ JavaScript Öе¼ÈëͼƬÓÐÁ½ÖÖÖ÷ÒªÒªÁ죺

1. ʹÓà ±êÇ©

ÕâÊÇ×î¼òÆÓµÄÒªÁ죬ֻÐèҪʹÓà HTML ±êÇ©À´Ö¸¶¨Í¼Æ¬µÄ·¾¶¡£

@@##@@

µÇ¼ºó¸´ÖÆ

2. ʹÓà Image ¹¤¾ß

¸üÎÞаµÄÒªÁìÊÇʹÓà JavaScript Image ¹¤¾ß¡£ÕâÔÊÐíÄúÔÚ¼ÓÔØͼÏñ֮ǰ¶ÔÆä¾ÙÐвÙ×÷£¬ÀýÈçµ÷½â¾Þϸ»ò²Ã¼ô¡£

const image = new Image();
image.src = "path/to/image.jpg";

image.onload = function() {
  // ͼƬ¼ÓÔØÍê±ÏºóÖ´Ðд˺¯Êý
};

µÇ¼ºó¸´ÖÆ

Ïêϸ˵Ã÷

ʹÓà ±êÇ©

±êÇ©ÊÇ HTML ÖÐÓÃÓÚÏÔʾͼÏñµÄ±ê×¼ÔªËØ¡£src ÊôÐÔÖ¸¶¨Í¼ÏñµÄ·¾¶¡£alt ÊôÐÔÌṩͼÏñµÄÌæ»»Îı¾£¬Õâ¹ØÓÚ¸¨Öú¹¦Ð§ºÍËÑË÷ÒýÇæÓÅ»¯ºÜÖ÷Òª¡£

Óŵ㣺

¼òÆÓÒ×ÓÃ

ÔÚËùÓÐä¯ÀÀÆ÷ÖлñµÃÖ§³Ö

Èõµã£º

²»¿É¶¯Ì¬¼ÓÔØͼÏñ£¨ÔÚÒ³Ãæ¼ÓÔغó£©

ȱÉÙ¶ÔͼÏñ²Ù×÷µÄ¿ØÖÆ

ʹÓà Image ¹¤¾ß

Image ¹¤¾ßÔÊÐíÄúÔÚ¼ÓÔØͼÏñ֮ǰ¶ÔÆä¾ÙÐвÙ×÷¡£¿ÉÒÔʹÓà src ÊôÐÔÉèÖÃͼÏñµÄ·¾¶£¬onload ÊÂÎñÕìÌýÆ÷½«ÔÚͼÏñ¼ÓÔØÍê³Éºó´¥·¢¡£

image.width = 200;  // ÉèÖÃͼƬµÄ¿í¶È
image.height = 200; // ÉèÖÃͼƬµÄ¸ß¶È
image.style.borderRadius = "50%";  // ÉèÖÃͼƬµÄ±ß¿ò°ë¾¶

µÇ¼ºó¸´ÖÆ

Óŵ㣺

ÔÊÐí¶¯Ì¬¼ÓÔØͼÏñ

Ìṩ¶ÔͼÏñ²Ù×÷µÄ¿ØÖÆ

Èõµã£º

±È ±êÇ©ÖØ´ó

ÔÚ¾Éä¯ÀÀÆ÷ÖпÉÄܲ»Ö§³Ö

ÒÔÉϾÍÊÇjsÔõôµ¼ÈëͼƬµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ