相关疑难解决方法(0)

在Typescript中访问SASS值(来自variables.scss的$ colors)(Angular2 ionic2)

在Ionic 2中,我想$colors从文件"[my project]\src\theme\variables.scss"中访问变量.

该文件包含:

$colors: (
  primary:    #387ef5,
  secondary:  #32db64,
  danger:     #f53d3d,
  light:      #f4f4f4,
  dark:       #222,
  favorite:   #69BB7B
);
Run Code Online (Sandbox Code Playgroud)

在一个组件中,我画一个画布.它看起来像这样:

import {Component, Input, ViewChild, ElementRef} from '@angular/core';

@Component({
    selector: 'my-graph',
})
@View({
    template: `<canvas #myGraph class='myGraph'
     [attr.width]='_size'
     [attr.height]='_size'></canvas>`,
})

export class MyGraphDiagram {
    private _size: number;

    // get the element with the #myGraph on it
    @ViewChild("myGraph") myGraph: ElementRef; 

    constructor(){
        this._size = 150;
    }

    ngAfterViewInit() { // wait for the view to init before using the element

      let context: …
Run Code Online (Sandbox Code Playgroud)

sass typescript ionic2 angular

41
推荐指数
4
解决办法
3万
查看次数

标签 统计

angular ×1

ionic2 ×1

sass ×1

typescript ×1