Have you noticed that you can use CoffeeScript in RunJS to write scripts and Less CSS to write styles.
Let's take a look at the Demo code:
CoffeeScript:
# Assignment:
Number = 42
Opposite = true
# Conditions:
Number =-42 if opposite
# Functions:
Square = (x)-> x * x
# Arrays:
List = [1, 2, 3, 4, 5]
# Objects:
Math =
Root: Math. sqrt
Square: square
Cube: (x)-> x * square x
# Splats:
Race = (winner, runners...)->
Print winner, runners
# Existence:
Alert "I knew it !" If elvis?
# Array comprehensions:
Cubes = (math. cube num for num in list)
Document. write "Result:" + cubes
LESS:
@ Bgcolor: # CCC;
Body {
Background-color: @ bgcolor;
}
However, by default, RunJS uses JavaScript and CSS. How can I enable CoffeeScript and Less CSS?
Enable CoffeeScript
Move the cursor to the JavaScript panel and click JavaScript, as shown in:
The script selection dialog box is displayed. Select CoffeeScript and click OK:
In the same way, you can click CSS on the CSS editing panel to choose to write styles with Less CSS:
Note:
CoffeeScript, a programming language built on JavaScript, is compiled into efficient JavaScript, so that you can run it on a web browser, or through a Node such as for server applications. js technologies. The compilation process is usually very simple. The generated JavaScript is consistent with many best practices. Details
Less CSS is a widely used CSS Preprocessor that extends CSS with simple syntax and variables to reduce the amount of CSS code. Details
Now let's try to use RunJS that supports CoffeeScript and Less CSS.
Http://runjs.cn