Skip to content

Install Sling

Daniel Puckowski edited this page Aug 3, 2021 · 1 revision

Download and install Sling with the following npm command:

npm i slingjs

Refer to the project at Sling.js for an example on how to integrate Sling.js with Webpack.

The following is an example of Sling.js usage without a build step:

import { mount, textNode, markup } from 'https://cdn.skypack.dev/slingjs';

class HelloWorldComponent {
  constructor() {
  }

  view() {
    return markup('h1', {
      attrs: {
        id: 'divRouterOutlet'
      },
      children: [
        textNode('Hello, world!')
      ]
    });
  }
}

mount('divRouterOutlet', new HelloWorldComponent());

The following is another example of Sling.js usage without a build step:

import { mount, textNode, markup } from 'https://unpkg.com/slingjs@10.1.2/sling.min.js';

class HelloWorldComponent {
  constructor() {
  }

  view() {
    return markup('h1', {
      attrs: {
        id: 'divRouterOutlet'
      },
      children: [
        textNode('Hello, world!')
      ]
    });
  }
}

mount('divRouterOutlet', new HelloWorldComponent());
Clone this wiki locally