如何从小提琴结合html,js和css

编程入门 行业动态 更新时间:2024-10-25 09:26:40
本文介绍了如何从小提琴结合html,js和css的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我知道这个问题很愚蠢,只是为了测试你的代码,但是通过将JS放在脚本<>和css下的风格<>下将它合并成一个代码不适合我!

I know the Question is silly and fiddle is only for testing your code, but combining that into one code via putting JS under script<> and css under style<> is not working for me!

指向我的代码

我按照其他人的建议使用了以下方法:

I have used the following way as suggested by others:

<html> <head> <style type="text/css"> table tr td { border: 1px solid; padding: 4px; }

<body> <div ng-controller="MyCtrl"> <button ng-click="processData(allText)"> Display CSV as Data Table </button> <div id="divID"> <table style="border:1px solid"> <tr ng-repeat="x in data"> <td ng-repeat="y in x" rowspan="{{y.rows}}" colspan="{{y.cols}}">{{ y.data }}</td> </tr> </table> </div>

<script src="ajax.googleapis/ajax/libs/angularjs/1.4.5/angular.min.js"></script> <script language="JavaScript" type="text/javascript"> var myApp = angular.module('myApp', []); myApp.controller("MyCtrl", function($scope) { $scope.allText = "RS#2|Through Air CS#2|Over Surface CS#2|\nin.|mm|in.|mm|\nB |3/32\n (a)|2.4 \n (a)|3/32 \n (a)|2.4 \n (a)|\nD |1/16\n (a)|1.6 \n (a)|1/8 \n (a)|3.2 \n (a)|\n"; $scope.processData = function(allText) { // split content based on new line var allTextLines = allText.split(/\|\n|\r\n/); var lines = []; var r, c; for (var i = 0; i < allTextLines.length; i++) { // split content based on comma var data = allTextLines[i].split('|'); var temp = []; for (var j = 0; j < data.length; j++) { if (data[j].indexOf("RS") !== -1) { r = data[j].split("#").reverse()[0]; } else { r = 0; } if (data[j].indexOf("CS") !== -1) { c = data[j].split("#").reverse()[0]; } else { c = 0; } temp.push({ "rows": r, "cols": c, "data": data[j].replace(/RS#.*$/, '').replace(/CS#.*$/, '') }); } lines.push(temp); } alert(JSON.stringify(lines)); $scope.data = lines; } });

推荐答案

问题是您正在使用外部JS框架AngularJS。您将不得不创建另一个加载Angular的脚本标签。有两种方法可以做到这一点:您可以下载角度源代码,然后将其加载到HTML中,或使用CDN。

The problem is that you are using an external JS framework, AngularJS. You will have to create another script tag which loads Angular as well. There are two ways you can do this: you can either download the angular source code and then load that into your HTML, or use a CDN.

要使用CDN,您可以在当前的< script> 标记上添加以下内容:

To use the CDN, you can just add the following above your current <script> tag:

<script src="ajax.googleapis/ajax/libs/angularjs/1.4.5/angular.min.js"></script>

您的最终输出应该如下所示:

Your final output should look like this:

<html> <head> <style type="text/css"> // CSS Content </style> </head> <body ng-app="myApp"> <!-- some html elements --> <script src="ajax.googleapis/ajax/libs/angularjs/1.4.5/angular.min.js"></script> <script language="JavaScript" type="text/javascript"> // more js here. </script> </body>

更多推荐

如何从小提琴结合html,js和css

本文发布于:2023-07-18 08:21:11,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:提琴   html   css   js

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!