Codeigniter: How to include javascript files

前端 未结 6 618
一向
一向 2020-12-08 21:10

Hello I just started working with CodeIgniter framework. My current directory structure is

Demo(Project name)
 +System
 +Application
   -Controllers
      de         


        
6条回答
  •  臣服心动
    2020-12-08 21:51

    You need to use the base_url() to include the javascript file in your VIEW.

    So, in the view_demo.php file:

    
    
    

    You will need the URL helper loaded. To load the helper you need to put on your demo.php controller:

    $this->load->helper('url');
    

    You can also autoload on \config\autoload.php on the helpers array.

    More info about base_url(): http://www.codeigniter.com/user_guide/helpers/url_helper.html#base_url https://codeigniter.com/user_guide/general/styleguide.html#short-open-tags

提交回复
热议问题