How to add/compile/link an external CSS in AppDesigner, same with JQuery

5 次查看(过去 30 天)
We have this project, created category/by folder (css folder, views folder (html), js folder). I use AppDesigner and embed my index.html and run but it doesn't load all the styles and jquery. How can I link/compile it?

回答(1 个)

Rushikesh
Rushikesh 2024-10-11
Hello John,
I understand you're facing an issue where external CSS and JS scripts linked in your HTML file aren't loading in MATLAB App Designer's HTML component. Let's address this step-by-step:
Root directory
|- views
|- index.html
|- CSS
|- style.css
|- JS
|- script.js
Here are some steps to resolve this issue:
1. According to the MATLAB documentation for the ‘uihtml component, referenced files like CSS and JS scripts should be in the same folder or a subfolder of your ‘index.html’ file. Therefore, consider moving your index.html file out of the views folder and into the root directory, where the CSS and JS folders are located.
2. Ensure that the paths to your CSS and JS files in ‘index.html’ are relative to the file's location or use full paths. For example:
<script src="./JS/script.js"></script>
3. The ‘uihtmlcomponent in MATLAB cannot access third-party JavaScript libraries such as ‘jquery.min.js’ via a Content Delivery Network (CDN). Therefore, you need to download libraries like jquery.min.js and place them in your project directory.
Example: root >> JS folder >> jquery.min.js
Hope this helps.

类别

Help CenterFile Exchange 中查找有关 Manage Products 的更多信息

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by