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

thinkphpÖÐÔõôÉèÖÃCSSºÍJavaScript±äÁ¿

Ò»¡¢ÉèÖà CSS ±äÁ¿

1.1 ÔÚ¿ØÖÆÆ÷Öнç˵±äÁ¿

Ê×ÏÈ£¬ÔÚ¿ØÖÆÆ÷Öнç˵ CSS ±äÁ¿¡£¿ÉÒÔͨ¹ýʹÓà $this->assign() º¯Êý½« CSS ±äÁ¿¸³Öµ¸øÄ£°åÎļþ¡£ÀýÈ磺

$this->assign('bg_color', '#ffffff'); // ½« #ffffff ¸³Öµ¸ø $bg_color

µÇ¼ºó¸´ÖÆ

1.2 ÔÚÄ£°åÎļþÖÐʹÓñäÁ¿

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

½ÓÏÂÀ´£¬ÎÒÃÇÐèÒªÔÚÄ£°åÎļþÖÐʹÓñäÁ¿¡£Õâ¿ÉÒÔͨ¹ýʹÓà { $var_name } Óï¾äÀ´ÊµÏÖ¡£ÔÚ±¾ÀýÖУ¬ÎÒÃÇ¿ÉÒÔÔÚ CSS ÎļþÖÐʹÓà $bg_color Åä¾°ÑÕÉ«±äÁ¿£¬ÈçÏÂËùʾ£º

body {
    background-color: { $bg_color };
}

µÇ¼ºó¸´ÖÆ

1.3 ÔÚÊÓͼÎļþÖÐÊä³ö CSS

×îºó£¬ÎÒÃÇÐèÒªÔÚÊÓͼÎļþÖÐÊä³ö CSS¡£¿ÉÒÔͨ¹ýʹÓà { volist } Óï¾äÀ´ÊµÏÖ¡£ÔÚ±¾ÀýÖУ¬ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏ·½·¨Êä³ö CSS Îļþ£º

<link rel="stylesheet" type="text/css" href="{: url(/help/&) }">

µÇ¼ºó¸´ÖÆ

¶þ¡¢ÉèÖà JavaScript ±äÁ¿

2.1 ÔÚ¿ØÖÆÆ÷Öнç˵±äÁ¿

Ê×ÏÈ£¬ÔÚ¿ØÖÆÆ÷Öнç˵ JavaScript ±äÁ¿¡£¿ÉÒÔͨ¹ýʹÓà $this->assign() º¯Êý½« JavaScript ±äÁ¿¸³Öµ¸øÄ£°åÎļþ¡£ÀýÈ磺

$this->assign('user_id', 1001); // ½« 1001 ¸³Öµ¸ø $user_id

µÇ¼ºó¸´ÖÆ

2.2 ÔÚÄ£°åÎļþÖÐʹÓñäÁ¿

½ÓÏÂÀ´£¬ÎÒÃÇÐèÒªÔÚÄ£°åÎļþÖÐʹÓñäÁ¿¡£¿ÉÒÔͨ¹ýʹÓà { $var_name } Óï¾äÀ´ÊµÏÖ¡£ÔÚ±¾ÀýÖУ¬ÎÒÃÇ¿ÉÒÔÔÚ JavaScript ÎļþÖÐʹÓà $user_id Óû§ ID ±äÁ¿£¬ÈçÏÂËùʾ£º

var userId = { $user_id };

µÇ¼ºó¸´ÖÆ

2.3 ÔÚÊÓͼÎļþÖÐÊä³ö JavaScript

×îºó£¬ÎÒÃÇÐèÒªÔÚÊÓͼÎļþÖÐÊä³ö JavaScript¡£¿ÉÒÔͨ¹ýʹÓà { volist } Óï¾äÀ´ÊµÏÖ¡£ÔÚ±¾ÀýÖУ¬ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏ·½·¨Êä³ö JavaScript Îļþ£º

<script type="text/javascript" src="{: url(/help/&) }"></script>

µÇ¼ºó¸´ÖÆ

ÒÔÉϾÍÊÇthinkphpÖÐÔõôÉèÖÃCSSºÍJavaScript±äÁ¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

QR code
ÍøÕ¾µØͼ