如何将“$”字符串添加到插值中?

时间:2017-06-20 11:05:17

标签: css sass interpolation

说我想通过向'$'添加插值来产生$small,换句话说,通过将字符串'$'连接到插值来产生$#{value} 。像这样:

"$" + #{value}

或者这个:

@mixin prog-prop($property-name, $mq-values){
  @each $mq in $mq-values{
    @include mq(#{nth($mq, 1)}){ #{$property-name}: #{nth($mq, 2)} }
  }
}

他们似乎都没有在sass / scss中工作。这有一个有用的语法吗?

我需要这个,因为我正在构建这个接受媒体查询名称的mixin(它来自我的框架,太长时间无法解释,并且有点offtopic)并且我想在传递参数时剥离美元:< / p>

    <title>Some Title</title>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <body>
    <h1 id="header">Collection</h1>

    <div id="list">

    <div id='p1'>
    <p>First Paragraph</p>
    <p>Abbot and Costello - Africa Screams</p>
    </div>

    <div id='p2'>
    <p>Second Paragraph</p>
    <p>Abbot and Costello - Frank/Meet</p>
    </div>

    <div id='p3'>
    <p>Third Paragraph</p>
    <p>addin</p>
    </div>

    <div id='p4'>
    <p>Forth Paragraph</p>
    <p>Begins</p>
    </div>

    </div>
    </body>
<script type="text/javascript">
    (function ($) {
      jQuery.expr[':'].Contains = function(a,i,m){
        return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0;
      };

      function listFilter(header, list) {
        $(list).find('p').hide();
        var form = $("<form>").attr({"class":"filterform","action":"#"}),
            input = $("<input>").attr({"class":"filterinput","type":"text"}),
            search = $("<input>").attr({"class":"filterbutton","type":"button","name":"btn1","value":"Search"});

        $(form).append(search).appendTo(header);
    $(search).on('click', function () {
          var filter = $(input).val();

          $(list).find('p').hide();

          if(filter) {
            $(list).find("p:Contains("+filter+")").show();
          }
        });
      }

      $(document).ready(function () {
        listFilter($("#header"), $("#list"));
      });
    }(jQuery));
</script>

1 个答案:

答案 0 :(得分:0)

我不知道你为什么要这样做,但这是一种方式:

$value:'string';

$value: '$#{$value}';

.value{
  content: $value;
}