scss Mixins错误

时间:2016-08-30 09:49:52

标签: css sass mixins

以下scss mixin有编译错误
" ...之后的无效CSS(基数,$ base)":预期")",&#34 ;;" 无法找到错误,请帮助

// Variables for Materiel colours
$primary         : #0293FF;
$primary-dark    : darken($primary,25%);
$primary-light   : lighten($primary,75%);
$accent          : #FF5252;

$text            : #ffffff;
$primary-text    : #333333;
$secondary-text  : #727272;
$divider         : #B6B6B6;
$base            : #FAFAFA;

$palette:    (primary, $primary),
            (primary-dark, $primary-dark),
            (primary-light, $primary-light),
            (text, $text),
            (primary-text, $primary-text,
            (secondary-text, $secondary-text),
            (accent, $accent),
            (divider, $divider),
            (base, $base);

@each $palette , $color in $palette  {
  .colour-#{$palette } {
    color: $color;
  }
   .bg-#{$palette } {
    background-color: $color;
  }
}

2 个答案:

答案 0 :(得分:1)

你在$ primary-text之后错过了一个结束括号吗?

$palette:    (primary, $primary),
            (primary-dark, $primary-dark),
            (primary-light, $primary-light),
            (text, $text),
            (primary-text, $primary-text),
            (secondary-text, $secondary-text),
            (accent, $accent),
            (divider, $divider),
            (base, $base);

答案 1 :(得分:0)

如果你想使用vars map,你应该像这样写“key_name”:$ value

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:alpha="180"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="24dp"
        android:layout_marginRight="24dp"
        android:layout_marginTop="24dp"
        android:background="@drawable/actionbar_selector"
        android:orientation="vertical"
        android:weightSum="1">

        <ImageView
            android:id="@+id/imageView4"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="8dp"
            android:src="@drawable/ic_error_outline" />

        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="16dp"
            android:text="@string/drive_carefully_title"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="@color/blue_light" />

        <TextView
            android:id="@+id/textView6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_marginTop="32dp"
            android:text="@string/drive_carefully_message"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="@color/blue_light" />

        <TextView
            android:id="@+id/ok_button"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_marginBottom="16dp"
            android:layout_marginTop="32dp"
            android:layout_weight="0.18"
            android:paddingBottom="8dp"
            android:paddingLeft="16dp"
            android:paddingRight="8dp"
            android:paddingTop="8dp"
            android:autoText="false"
            android:background="@drawable/ok_button"
            android:textColor="@color/blue_medium"
            android:text="@string/ok"
            android:textSize="24dp"
            android:clickable="true"
            android:layout_marginLeft="64dp"
            android:gravity="center"
            android:textStyle="bold">
        </TextView>

    </LinearLayout>

</RelativeLayout>

问候:)